Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Rabobank GET /v3/accountsDemonstrates a call to a Rabobank API. Specifically this makes a call to the "Accounts AIS sb" API to deliver all the consented payments accounts for a specific Rabobank customer. (This includes source code to for signing requests for PSD2 APIs) For more information, see https://developer-sandbox.rabobank.nl/reference/accounts-ais-sb/3-0-8
IncludeFile "CkJsonObject.pb" IncludeFile "CkDateTime.pb" IncludeFile "CkPrivateKey.pb" IncludeFile "CkHttp.pb" IncludeFile "CkCrypt2.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkRsa.pb" IncludeFile "CkCert.pb" IncludeFile "CkBinData.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; Implements the following CURL command: ; curl --request GET \ ; --url https://api-sandbox.rabobank.nl/openapi/sandbox/payments/account-information/ais/v3/accounts \ ; --header 'accept: application/json' \ ; --header 'authorization: Bearer REPLACE_BEARER_TOKEN' \ ; --header 'date: REPLACE_THIS_VALUE' \ ; --header 'digest: REPLACE_THIS_VALUE' \ ; --header 'psu-ip-address: OPTIONAL' \ ; --header 'signature: REPLACE_THIS_VALUE' \ ; --header 'tpp-signature-certificate: MIIDkDCCAnigA ... cwE6gUl0rMA==' \ ; --header 'x-ibm-client-id: Client ID' \ ; --header 'x-request-id: REPLACE_THIS_VALUE' ; Load the previously fetched OAuth2 access token. jsonToken.i = CkJsonObject::ckCreate() If jsonToken.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/rabobank.json") If success = 0 Debug CkJsonObject::ckLastErrorText(jsonToken) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf ; This adds the "authorization: Bearer REPLACE_BEARER_TOKEN" header. CkHttp::setCkAuthToken(http, CkJsonObject::ckStringOf(jsonToken,"access_token")) ; This is the TTP Signature certificate: The certificate used for signing the request. sbTppCert.i = CkStringBuilder::ckCreate() If sbTppCert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbTppCert,"MIIDkDCCAnigAwIBAgIEWs3AJDANBgkqhkiG9w0BAQsFADCBiTELMAkGA1UEBhMC") CkStringBuilder::ckAppend(sbTppCert,"TkwxEDAOBgNVBAgMB1V0cmVjaHQxEDAOBgNVBAcMB1V0cmVjaHQxETAPBgNVBAoM") CkStringBuilder::ckAppend(sbTppCert,"CFJhYm9iYW5rMRwwGgYDVQQLDBNPbmxpbmUgVHJhbnNhY3Rpb25zMSUwIwYDVQQD") CkStringBuilder::ckAppend(sbTppCert,"DBxQU0QyIEFQSSBQSSBTZXJ2aWNlcyBTYW5kYm94MB4XDTE4MDQxMTA3NTgyOFoX") CkStringBuilder::ckAppend(sbTppCert,"DTIzMDQxMTA3NTgyOFowgYkxCzAJBgNVBAYTAk5MMRAwDgYDVQQIDAdVdHJlY2h0") CkStringBuilder::ckAppend(sbTppCert,"MRAwDgYDVQQHDAdVdHJlY2h0MREwDwYDVQQKDAhSYWJvYmFuazEcMBoGA1UECwwT") CkStringBuilder::ckAppend(sbTppCert,"T25saW5lIFRyYW5zYWN0aW9uczElMCMGA1UEAwwcUFNEMiBBUEkgUEkgU2Vydmlj") CkStringBuilder::ckAppend(sbTppCert,"ZXMgU2FuZGJveDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANoAjqGW") CkStringBuilder::ckAppend(sbTppCert,"UgCIm2F+0sBSEwLal+T3u+uldLikpxHCB8iL1GD7FrRjcA+MVsxhvHly7vRsHK+t") CkStringBuilder::ckAppend(sbTppCert,"QyMSaeK782RHpY33qxPLc8LmoQLb2EuiQxXj9POYkYBQ74qkrZnvKVlR3WoyQWeD") CkStringBuilder::ckAppend(sbTppCert,"OXnSY2wbNFfkP8ET4ElwyuIIEriwYhab0OIrnnrO8X82/SPZxHwEd3aQjQ6uhiw8") CkStringBuilder::ckAppend(sbTppCert,"paDspJbS5WjEfuwY16KVVUYlhbtAwGjvc6aK0NBm+LH9fMLpAE6gfGZNy0gzMDor") CkStringBuilder::ckAppend(sbTppCert,"VNbkQK1IoAGD8p9ZHdB0F3FwkILEjUiQW6nK+/fKDNJ0TBbpgZUpY8bR460qzxKd") CkStringBuilder::ckAppend(sbTppCert,"eZ1yPDqX2Cjh6fkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAYL4iD6noMJAt63kD") CkStringBuilder::ckAppend(sbTppCert,"ED4RB2mII/lssvHhcxuDpOm3Ims9urubFWEpvV5TgIBAxy9PBinOdjhO1kGJJnYi") CkStringBuilder::ckAppend(sbTppCert,"7F1jv1qnZwTV1JhYbvxv3+vk0jaiu7Ew7G3ASlzruXyMhN6t6jk9MpaWGl5Uw1T+") CkStringBuilder::ckAppend(sbTppCert,"gNRUcWQRR44g3ahQRIS/UHkaV+vcpOa8j186/1X0ULHfbcVQk4LMmJeXqNs8sBAU") CkStringBuilder::ckAppend(sbTppCert,"dKU/c6ssvj8jfJ4SfrurcBhY5UBTOdQOXTPY85aU3iFloerx7Oi9EHewxInOrU5X") CkStringBuilder::ckAppend(sbTppCert,"zqqTz2AQPXezexVeAQxP27lzqCmYC7CFiam6QBr06VebkmnPLfs76n8CDc1cwE6g") CkStringBuilder::ckAppend(sbTppCert,"Ul0rMA==") CkHttp::ckSetRequestHeader(http,"tpp-signature-certificate",CkStringBuilder::ckGetAsString(sbTppCert)) ; ---------------------------------------------------------------- ; We're not going to add the psu-ip-address header in this example. ; ---------------------------------------------------------------- ; X-Request-ID header... ; Generate a UUID v4. crypt.i = CkCrypt2::ckCreate() If crypt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf xRequestId.s = CkCrypt2::ckGenerateUuid(crypt) CkHttp::ckSetRequestHeader(http,"x-request-id",xRequestId) ; ---------------------------------------------------------------- ; Date header... dt.i = CkDateTime::ckCreate() If dt.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkDateTime::ckSetFromCurrentSystemTime(dt) dateHdrVal.s = CkDateTime::ckGetAsRfc822(dt,0) ; The desire date/time format is the "RFC822" format. CkHttp::ckSetRequestHeader(http,"Date",dateHdrVal) ; ---------------------------------------------------------------- ; Digest header... CkCrypt2::setCkHashAlgorithm(crypt, "SHA256") CkCrypt2::setCkEncodingMode(crypt, "base64") ; A GET request has no HTTP request body. Therefore the payload is the empty string. payload.s = "" payloadDigest.s = CkCrypt2::ckHashStringENC(crypt,payload) sbDigestHdrVal.i = CkStringBuilder::ckCreate() If sbDigestHdrVal.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbDigestHdrVal,"SHA-256=") CkStringBuilder::ckAppend(sbDigestHdrVal,payloadDigest) CkHttp::ckSetRequestHeader(http,"digest",CkStringBuilder::ckGetAsString(sbDigestHdrVal)) ; ---------------------------------------------------------------- ; The HTTP request needs to be signed for PSD2 API's... ; Create the signing string (to use in signing the HTTP request). ; See https://developer.rabobank.nl/signing-requests-psd2-apis ; ; For "account information" HTTP requests, we must use the following headers in the signing string. ; date ; digest ; x-request-id sbStringToSign.i = CkStringBuilder::ckCreate() If sbStringToSign.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbStringToSign,"date: ") CkStringBuilder::ckAppendLine(sbStringToSign,dateHdrVal,0) CkStringBuilder::ckAppend(sbStringToSign,"digest: ") CkStringBuilder::ckAppendLine(sbStringToSign,CkStringBuilder::ckGetAsString(sbDigestHdrVal),0) CkStringBuilder::ckAppend(sbStringToSign,"x-request-id: ") CkStringBuilder::ckAppend(sbStringToSign,xRequestId) ; ---------------------------------------------------------------- ; Sign with our private key... sbPrivKey.i = CkStringBuilder::ckCreate() If sbPrivKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbPrivKey,"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDaAI6hllIAiJth") CkStringBuilder::ckAppend(sbPrivKey,"ftLAUhMC2pfk97vrpXS4pKcRwgfIi9Rg+xa0Y3APjFbMYbx5cu70bByvrUMjEmni") CkStringBuilder::ckAppend(sbPrivKey,"u/NkR6WN96sTy3PC5qEC29hLokMV4/TzmJGAUO+KpK2Z7ylZUd1qMkFngzl50mNs") CkStringBuilder::ckAppend(sbPrivKey,"GzRX5D/BE+BJcMriCBK4sGIWm9DiK556zvF/Nv0j2cR8BHd2kI0OroYsPKWg7KSW") CkStringBuilder::ckAppend(sbPrivKey,"0uVoxH7sGNeilVVGJYW7QMBo73OmitDQZvix/XzC6QBOoHxmTctIMzA6K1TW5ECt") CkStringBuilder::ckAppend(sbPrivKey,"SKABg/KfWR3QdBdxcJCCxI1IkFupyvv3ygzSdEwW6YGVKWPG0eOtKs8SnXmdcjw6") CkStringBuilder::ckAppend(sbPrivKey,"l9go4en5AgMBAAECggEAB8nsTqalwGIhFw8mbXuhNUFlGuek/arYLD6pv28swwQH") CkStringBuilder::ckAppend(sbPrivKey,"7v0ZlxFUcCHF+iBl0PsDwZTZQ4ePtgGS6ehoLkWHCzb1lEv5E1YVG5qKNE2UUwRl") CkStringBuilder::ckAppend(sbPrivKey,"fIyPakO6AzyV/UF3uzq7C+/GuXGNTKZxKewg5yD/DCFvKoCOpxu9u36FyqP/hw0S") CkStringBuilder::ckAppend(sbPrivKey,"ADVlmp35/zoPDPZzu1j4FiCo0pJ9LwJcHxeJHopNAKDw9k6I4z/grskdgupsGzK2") CkStringBuilder::ckAppend(sbPrivKey,"BiGiQ/+wmmO68/6Xa6KWfpr1PQ6ODJHgzZsdGCVi6Ebaqlj6BbsYWxP6h3lrsGt+") CkStringBuilder::ckAppend(sbPrivKey,"LmHBaN2jCD6cDp+lihqFgnm8hfdv0lmbPilp71EDfwKBgQD6U8PBzZtN8yXm5WuS") CkStringBuilder::ckAppend(sbPrivKey,"NL+/8q5GjNmeTJBSo1gM6Y8vOT4QAE147LbVuVBDwyHPoSrNejePae6Q14PswjBy") CkStringBuilder::ckAppend(sbPrivKey,"T7B8DZ0OeQyGa3trrFg/ib7Vv4ZMvJqX9+WzBrzZsxTg7oCKHzmCR4vIRItKHH3z") CkStringBuilder::ckAppend(sbPrivKey,"Wnnhqlo8ic2AZ2O43cdJosbO1wKBgQDe8UODOLu0vnHohOKeUqF3w/ZOB2+83/js") CkStringBuilder::ckAppend(sbPrivKey,"YyUbSkzsGvHIwTjObuMUFTQvdMZ6IkIyJdfnDZIbvlBSD8tzL5iKFTNCK2nL1i4G") CkStringBuilder::ckAppend(sbPrivKey,"iFr0CYLaHAlhJ5GEbTrTMDoJeBPerZq83HPrSa/Wb0xO18QTWsoVQPFfPFbbcQyI") CkStringBuilder::ckAppend(sbPrivKey,"9ryJ2iIDrwKBgQC6kuAefG46ZPVk6K2KZUJdgDUgZC52a75NuW0RAqszmUiGiJM1") CkStringBuilder::ckAppend(sbPrivKey,"g8ip9tq6BqAWrprGV0c93shusBKlzf5p1LdHXqYmeVY6gbWVhPipMrNHgN5KJ3BZ") CkStringBuilder::ckAppend(sbPrivKey,"v+w1yNnMsErpcxne2HL2hPjMJTpj3GSLkm2xIlTrNhIyl9ydlr7IRUhENQKBgQCv") CkStringBuilder::ckAppend(sbPrivKey,"i6HxbXa/90WSJTCcIcxqla8X+dsOCf3jhJ3vQy4Wq5C+1wZ35fCAG8Ifq/+so9Uj") CkStringBuilder::ckAppend(sbPrivKey,"z5CVqqXlmpF8TFuSs2OVNuRJsg14J4nOMwgLKIIUZAcurQ10DN5I9Kx+UEK1EFXL") CkStringBuilder::ckAppend(sbPrivKey,"aHsORdNjMfgQDO2jn9WHrr9gkg6CdB2+qyoCEfS+mQKBgBW08lcy9V5RzRWb/v/j") CkStringBuilder::ckAppend(sbPrivKey,"xsc7ovmgAhCJhDeV7dPbx4HbFeoQJlbA8g1thdcFlcatSGyNDbvNE1GPSd4NhkpR") CkStringBuilder::ckAppend(sbPrivKey,"Y6Hfv53kdEzjVkEtU8lUdL7HNVJqX7bU7oZlfbYcwxWQ1Gg8C1oLIAyEt71slQtd") CkStringBuilder::ckAppend(sbPrivKey,"RiNYBRZTQe2F0wxbXnuUqLAw") privKey.i = CkPrivateKey::ckCreate() If privKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkPrivateKey::ckLoadPem(privKey,CkStringBuilder::ckGetAsString(sbPrivKey)) If success = 0 Debug CkPrivateKey::ckLastErrorText(privKey) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) ProcedureReturn EndIf rsa.i = CkRsa::ckCreate() If rsa.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkRsa::ckImportPrivateKeyObj(rsa,privKey) If success = 0 Debug CkRsa::ckLastErrorText(rsa) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) ProcedureReturn EndIf CkRsa::setCkEncodingMode(rsa, "base64") b64Signature.s = CkRsa::ckSignStringENC(rsa,CkStringBuilder::ckGetAsString(sbStringToSign),"SHA256") ; ---------------------------------------------------------------- ; Add the "signature" header. ; ; The signature header will look like this: ; signature: keyId="1523433508",algorithm="rsa-sha512",headers="date digest x-request-id",signature="y5o7gKxmfA6AT6...blE1A9Q==" ; ; The keyId is the serial number of the certificate as defined in 'TPP-Signing-Certificate' header, the format should be Integer not hex. cert.i = CkCert::ckCreate() If cert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkCert::ckSetFromEncoded(cert,CkStringBuilder::ckGetAsString(sbTppCert)) If success = 0 Debug CkCert::ckLastErrorText(cert) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) ProcedureReturn EndIf sbSigHdrVal.i = CkStringBuilder::ckCreate() If sbSigHdrVal.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkStringBuilder::ckAppend(sbSigHdrVal,"keyId=" + Chr(34)) CkStringBuilder::ckAppend(sbSigHdrVal,CkCert::ckSerialDecimal(cert)) CkStringBuilder::ckAppend(sbSigHdrVal,Chr(34) + ",") CkStringBuilder::ckAppend(sbSigHdrVal,"algorithm=" + Chr(34) + "rsa-sha256" + Chr(34) + ",") CkStringBuilder::ckAppend(sbSigHdrVal,"headers=" + Chr(34) + "date digest x-request-id" + Chr(34) + ",") CkStringBuilder::ckAppend(sbSigHdrVal,"signature=" + Chr(34)) CkStringBuilder::ckAppend(sbSigHdrVal,b64Signature) CkStringBuilder::ckAppend(sbSigHdrVal,Chr(34)) CkHttp::ckSetRequestHeader(http,"signature",CkStringBuilder::ckGetAsString(sbSigHdrVal)) ; ---------------------------------------------------------------- ; Add remaining headers... CkHttp::ckSetRequestHeader(http,"x-ibm-client-id","YOUR_APP_CLIENT_ID") CkHttp::ckSetRequestHeader(http,"accept","application/json") ; ---------------------------------------------------------------- ; Add our certificate and key for mutual TLS ; (provide a registered X509 client certificate during TLS handhake) tlsCert.i = CkCert::ckCreate() If tlsCert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkCert::ckLoadFromFile(tlsCert,"qa_data/certs_and_keys/ING/example_client_tls.cer") If success = 0 Debug CkCert::ckLastErrorText(tlsCert) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) ProcedureReturn EndIf bdPrivKey.i = CkBinData::ckCreate() If bdPrivKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkBinData::ckLoadFile(bdPrivKey,"qa_data/certs_and_keys/ING/example_client_tls.key") If success = 0 Debug "Failed to load example_client_tls.key" CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) CkBinData::ckDispose(bdPrivKey) ProcedureReturn EndIf ; The OAuth 2.0 client_id for these certificates is e77d776b-90af-4684-bebc-521e5b2614dd. ; Please note down this client_id since you will need it in the next steps to call the API. tlsPrivKey.i = CkPrivateKey::ckCreate() If tlsPrivKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkPrivateKey::ckLoadAnyFormat(tlsPrivKey,bdPrivKey,"") If success = 0 Debug CkPrivateKey::ckLastErrorText(tlsPrivKey) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(tlsPrivKey) ProcedureReturn EndIf ; Associate the private key with the certificate. success = CkCert::ckSetPrivateKey(tlsCert,tlsPrivKey) If success = 0 Debug CkCert::ckLastErrorText(tlsCert) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(tlsPrivKey) ProcedureReturn EndIf success = CkHttp::ckSetSslClientCert(http,tlsCert) If success = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(tlsPrivKey) ProcedureReturn EndIf ; ---------------------------------------------------------------- ; Finally, send the request... sbResponseBody.i = CkStringBuilder::ckCreate() If sbResponseBody.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkHttp::ckQuickGetSb(http,"https://api-sandbox.rabobank.nl/openapi/sandbox/payments/account-information/ais/v3/accounts",sbResponseBody) If success = 0 Debug CkHttp::ckLastErrorText(http) Debug CkStringBuilder::ckGetAsString(sbResponseBody) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(tlsPrivKey) CkStringBuilder::ckDispose(sbResponseBody) ProcedureReturn EndIf jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadSb(jResp,sbResponseBody) CkJsonObject::setCkEmitCompact(jResp, 0) Debug "Response Body:" Debug CkJsonObject::ckEmit(jResp) respStatusCode.i = CkHttp::ckLastStatus(http) Debug "Response Status Code = " + Str(respStatusCode) If respStatusCode >= 400 Debug "Response Header:" Debug CkHttp::ckLastHeader(http) Debug "Failed." CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(tlsPrivKey) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndIf ; Sample JSON response: ; (Sample code for parsing the JSON response is shown below) ; { ; "accounts": [ ; { ; "_links": { ; "account": "/v3/accounts/dW9od2VIVUhGVypIZHVpaGRhdWR3OGRoY", ; "balances": "/v3/accounts/dW9od2VIVUhGVypIZHVpaGRhdWR3OGRoY/balances", ; "transactions": "/v3/accounts/dW9od2VIVUhGVypIZHVpaGRhdWR3OGRoY/transactions" ; }, ; "currency": "EUR", ; "iban": "NL05RABO0812836782", ; "name": "Rosie Roy", ; "resourceId": "dW9od2VIVUhGVypIZHVpaGRhdWR3OGRoY", ; "status": "enabled" ; } ; ] ; } ; Sample code for parsing the JSON response... ; Use the following online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON v_linksAccount.s v_linksBalances.s v_linksTransactions.s currency.s iban.s name.s resourceId.s status.s i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jResp,"accounts") While i < count_i CkJsonObject::setCkI(jResp, i) v_linksAccount = CkJsonObject::ckStringOf(jResp,"accounts[i]._links.account") v_linksBalances = CkJsonObject::ckStringOf(jResp,"accounts[i]._links.balances") v_linksTransactions = CkJsonObject::ckStringOf(jResp,"accounts[i]._links.transactions") currency = CkJsonObject::ckStringOf(jResp,"accounts[i].currency") iban = CkJsonObject::ckStringOf(jResp,"accounts[i].iban") name = CkJsonObject::ckStringOf(jResp,"accounts[i].name") resourceId = CkJsonObject::ckStringOf(jResp,"accounts[i].resourceId") status = CkJsonObject::ckStringOf(jResp,"accounts[i].status") i = i + 1 Wend CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbTppCert) CkCrypt2::ckDispose(crypt) CkDateTime::ckDispose(dt) CkStringBuilder::ckDispose(sbDigestHdrVal) CkStringBuilder::ckDispose(sbStringToSign) CkStringBuilder::ckDispose(sbPrivKey) CkPrivateKey::ckDispose(privKey) CkRsa::ckDispose(rsa) CkCert::ckDispose(cert) CkStringBuilder::ckDispose(sbSigHdrVal) CkCert::ckDispose(tlsCert) CkBinData::ckDispose(bdPrivKey) CkPrivateKey::ckDispose(tlsPrivKey) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.