Lianja
Lianja
Isabel Connect List Accounts
See more Ibanity Examples
Get a list of accounts.Chilkat Lianja Downloads
llSuccess = .F.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// Implements the following CURL command:
// curl -X GET https://api.ibanity.com/isabel-connect/accounts \
// --cert certificate.pem:qwertyuiop1 \
// --key private_key.pem \
// -H "Authorization: Bearer access_token_1603365407" \
// -H "Accept: application/vnd.api+json"
// Ibanity provides the certificate + private key in PFX format. This example will use the .pfx instead of the pair of PEM files.
// (It is also possible to implement using Chilkat with the PEM files, but PFX is easier.)
llSuccess = loHttp.SetSslClientCertPfx("qa_data/pfx/my_ibanity_certificate.pfx","my_pfx_password")
if (llSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
return
endif
// Load the previously obtained access token.
loJsonToken = createobject("CkJsonObject")
llSuccess = loJsonToken.LoadFile("qa_data/tokens/isabel_access_token.json")
if (llSuccess = .F.) then
? "No existing access token."
release loHttp
release loJsonToken
return
endif
// This causes the "Authorization: Bearer ***" header to be added to the HTTP request.
loHttp.AuthToken = loJsonToken.StringOf("access_token")
loHttp.Accept = "application/vnd.api+json"
lcJsonStr = loHttp.QuickGetStr("https://api.ibanity.com/isabel-connect/accounts")
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loJsonToken
return
endif
loJResp = createobject("CkJsonObject")
loJResp.Load(lcJsonStr)
loJResp.EmitCompact = .F.
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
? "Response Header:"
? loHttp.LastResponseHeader
? "Failed."
release loHttp
release loJsonToken
release loJResp
return
endif
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": [
// {
// "id": "93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1",
// "type": "account"
// }
// ],
// "meta": {
// "paging": {
// "offset": 0,
// "total": 1
// }
// }
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
lnMetaPagingOffset = loJResp.IntOf("meta.paging.offset")
lnMetaPagingTotal = loJResp.IntOf("meta.paging.total")
i = 0
lnCount_i = loJResp.SizeOfArray("data")
do while i < lnCount_i
loJResp.I = i
lcId = loJResp.StringOf("data[i].id")
lcV_type = loJResp.StringOf("data[i].type")
i = i + 1
enddo
release loHttp
release loJsonToken
release loJResp