Xbase++
Xbase++
Populi Add Financial Aid Disbursement
See more Populi Examples
Demonstrates the Populi addFinancialAidDisbursement task.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oXml
LOCAL cAccessKey
LOCAL oRest
LOCAL nBAutoReconnect
LOCAL cResponseBody
LOCAL nDisbursement
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// First load the previously obtained API token.
// See Get Populi Access Token for sample code showing how to get the API token.
oXml := CreateObject("Chilkat.Xml")
nSuccess := oXml:LoadXmlFile("qa_data/tokens/populi_token.xml")
cAccessKey := oXml:GetChildContent("access_key")
IF (oXml:LastMethodSuccess != 1)
? "Did not find the access_key"
oXml:destroy()
RETURN
ENDIF
oRest := CreateObject("Chilkat.Rest")
// Connect using TLS.
// A single REST object, once connected, can be used for many Populi REST API calls.
// The auto-reconnect indicates that if the already-established HTTPS connection is closed,
// then it will be automatically re-established as needed.
nBAutoReconnect := 1
nSuccess := oRest:Connect("yourcollege.populi.co", 443, 1, nBAutoReconnect)
IF (nSuccess != 1)
? oRest:LastErrorText
oXml:destroy()
oRest:destroy()
RETURN
ENDIF
oRest:Authorization := cAccessKey
oRest:AddQueryParam("task", "addFinancialAidDisbursement")
oRest:AddQueryParam("person_id", "12345678")
oRest:AddQueryParam("award_id", "555555")
oRest:AddQueryParam("academic_term_id", "123")
oRest:AddQueryParam("scheduled_date", "2019-10-10")
oRest:AddQueryParam("amount", "12345")
cResponseBody := oRest:FullRequestFormUrlEncoded("POST", "/api/index.php")
IF (oRest:LastMethodSuccess != 1)
? oRest:LastErrorText
oXml:destroy()
oRest:destroy()
RETURN
ENDIF
// We should expect a 200 response if successful.
IF (oRest:ResponseStatusCode != 200)
? "Request Header: "
? oRest:LastRequestHeader
? "----"
? "Response StatusCode = " + Str(oRest:ResponseStatusCode)
? "Response StatusLine: " + oRest:ResponseStatusText
? "Response Header:"
? oRest:ResponseHeader
? "Response Body:"
? cResponseBody
oXml:destroy()
oRest:destroy()
RETURN
ENDIF
oXml:LoadXml(cResponseBody)
? oXml:GetXml()
// Sample response:
// Use this online tool to generate parsing code from sample XML:
// Generate Parsing Code from XML
// <?xml version="1.0" encoding="UTF-8"?>
// <result>
// <disbursement>123456</disbursement>
// </result>
nDisbursement := oXml:GetChildIntValue("disbursement")
oXml:destroy()
oRest:destroy()