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
(C) 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
#include <C_CkHttp.h> #include <C_CkJsonObject.h> #include <C_CkStringBuilder.h> #include <C_CkCrypt2.h> #include <C_CkDateTime.h> #include <C_CkPrivateKey.h> #include <C_CkRsa.h> #include <C_CkCert.h> #include <C_CkBinData.h> void ChilkatSample(void) { HCkHttp http; BOOL success; HCkJsonObject jsonToken; HCkStringBuilder sbTppCert; HCkCrypt2 crypt; const char *xRequestId; HCkDateTime dt; const char *dateHdrVal; const char *payload; const char *payloadDigest; HCkStringBuilder sbDigestHdrVal; HCkStringBuilder sbStringToSign; HCkStringBuilder sbPrivKey; HCkPrivateKey privKey; HCkRsa rsa; const char *b64Signature; HCkCert cert; HCkStringBuilder sbSigHdrVal; HCkCert tlsCert; HCkBinData bdPrivKey; HCkPrivateKey tlsPrivKey; HCkStringBuilder sbResponseBody; HCkJsonObject jResp; int respStatusCode; const char *v_linksAccount; const char *v_linksBalances; const char *v_linksTransactions; const char *currency; const char *iban; const char *name; const char *resourceId; const char *status; int i; int count_i; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttp_Create(); // 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 = CkJsonObject_Create(); success = CkJsonObject_LoadFile(jsonToken,"qa_data/tokens/rabobank.json"); if (success == FALSE) { printf("%s\n",CkJsonObject_lastErrorText(jsonToken)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); return; } // This adds the "authorization: Bearer REPLACE_BEARER_TOKEN" header. CkHttp_putAuthToken(http,CkJsonObject_stringOf(jsonToken,"access_token")); // This is the TTP Signature certificate: The certificate used for signing the request. sbTppCert = CkStringBuilder_Create(); CkStringBuilder_Append(sbTppCert,"MIIDkDCCAnigAwIBAgIEWs3AJDANBgkqhkiG9w0BAQsFADCBiTELMAkGA1UEBhMC"); CkStringBuilder_Append(sbTppCert,"TkwxEDAOBgNVBAgMB1V0cmVjaHQxEDAOBgNVBAcMB1V0cmVjaHQxETAPBgNVBAoM"); CkStringBuilder_Append(sbTppCert,"CFJhYm9iYW5rMRwwGgYDVQQLDBNPbmxpbmUgVHJhbnNhY3Rpb25zMSUwIwYDVQQD"); CkStringBuilder_Append(sbTppCert,"DBxQU0QyIEFQSSBQSSBTZXJ2aWNlcyBTYW5kYm94MB4XDTE4MDQxMTA3NTgyOFoX"); CkStringBuilder_Append(sbTppCert,"DTIzMDQxMTA3NTgyOFowgYkxCzAJBgNVBAYTAk5MMRAwDgYDVQQIDAdVdHJlY2h0"); CkStringBuilder_Append(sbTppCert,"MRAwDgYDVQQHDAdVdHJlY2h0MREwDwYDVQQKDAhSYWJvYmFuazEcMBoGA1UECwwT"); CkStringBuilder_Append(sbTppCert,"T25saW5lIFRyYW5zYWN0aW9uczElMCMGA1UEAwwcUFNEMiBBUEkgUEkgU2Vydmlj"); CkStringBuilder_Append(sbTppCert,"ZXMgU2FuZGJveDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANoAjqGW"); CkStringBuilder_Append(sbTppCert,"UgCIm2F+0sBSEwLal+T3u+uldLikpxHCB8iL1GD7FrRjcA+MVsxhvHly7vRsHK+t"); CkStringBuilder_Append(sbTppCert,"QyMSaeK782RHpY33qxPLc8LmoQLb2EuiQxXj9POYkYBQ74qkrZnvKVlR3WoyQWeD"); CkStringBuilder_Append(sbTppCert,"OXnSY2wbNFfkP8ET4ElwyuIIEriwYhab0OIrnnrO8X82/SPZxHwEd3aQjQ6uhiw8"); CkStringBuilder_Append(sbTppCert,"paDspJbS5WjEfuwY16KVVUYlhbtAwGjvc6aK0NBm+LH9fMLpAE6gfGZNy0gzMDor"); CkStringBuilder_Append(sbTppCert,"VNbkQK1IoAGD8p9ZHdB0F3FwkILEjUiQW6nK+/fKDNJ0TBbpgZUpY8bR460qzxKd"); CkStringBuilder_Append(sbTppCert,"eZ1yPDqX2Cjh6fkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAYL4iD6noMJAt63kD"); CkStringBuilder_Append(sbTppCert,"ED4RB2mII/lssvHhcxuDpOm3Ims9urubFWEpvV5TgIBAxy9PBinOdjhO1kGJJnYi"); CkStringBuilder_Append(sbTppCert,"7F1jv1qnZwTV1JhYbvxv3+vk0jaiu7Ew7G3ASlzruXyMhN6t6jk9MpaWGl5Uw1T+"); CkStringBuilder_Append(sbTppCert,"gNRUcWQRR44g3ahQRIS/UHkaV+vcpOa8j186/1X0ULHfbcVQk4LMmJeXqNs8sBAU"); CkStringBuilder_Append(sbTppCert,"dKU/c6ssvj8jfJ4SfrurcBhY5UBTOdQOXTPY85aU3iFloerx7Oi9EHewxInOrU5X"); CkStringBuilder_Append(sbTppCert,"zqqTz2AQPXezexVeAQxP27lzqCmYC7CFiam6QBr06VebkmnPLfs76n8CDc1cwE6g"); CkStringBuilder_Append(sbTppCert,"Ul0rMA=="); CkHttp_SetRequestHeader(http,"tpp-signature-certificate",CkStringBuilder_getAsString(sbTppCert)); // ---------------------------------------------------------------- // We're not going to add the psu-ip-address header in this example. // ---------------------------------------------------------------- // X-Request-ID header... // Generate a UUID v4. crypt = CkCrypt2_Create(); xRequestId = CkCrypt2_generateUuid(crypt); CkHttp_SetRequestHeader(http,"x-request-id",xRequestId); // ---------------------------------------------------------------- // Date header... dt = CkDateTime_Create(); CkDateTime_SetFromCurrentSystemTime(dt); dateHdrVal = CkDateTime_getAsRfc822(dt,FALSE); // The desire date/time format is the "RFC822" format. CkHttp_SetRequestHeader(http,"Date",dateHdrVal); // ---------------------------------------------------------------- // Digest header... CkCrypt2_putHashAlgorithm(crypt,"SHA256"); CkCrypt2_putEncodingMode(crypt,"base64"); // A GET request has no HTTP request body. Therefore the payload is the empty string. payload = ""; payloadDigest = CkCrypt2_hashStringENC(crypt,payload); sbDigestHdrVal = CkStringBuilder_Create(); CkStringBuilder_Append(sbDigestHdrVal,"SHA-256="); CkStringBuilder_Append(sbDigestHdrVal,payloadDigest); CkHttp_SetRequestHeader(http,"digest",CkStringBuilder_getAsString(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 = CkStringBuilder_Create(); CkStringBuilder_Append(sbStringToSign,"date: "); CkStringBuilder_AppendLine(sbStringToSign,dateHdrVal,FALSE); CkStringBuilder_Append(sbStringToSign,"digest: "); CkStringBuilder_AppendLine(sbStringToSign,CkStringBuilder_getAsString(sbDigestHdrVal),FALSE); CkStringBuilder_Append(sbStringToSign,"x-request-id: "); CkStringBuilder_Append(sbStringToSign,xRequestId); // ---------------------------------------------------------------- // Sign with our private key... sbPrivKey = CkStringBuilder_Create(); CkStringBuilder_Append(sbPrivKey,"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDaAI6hllIAiJth"); CkStringBuilder_Append(sbPrivKey,"ftLAUhMC2pfk97vrpXS4pKcRwgfIi9Rg+xa0Y3APjFbMYbx5cu70bByvrUMjEmni"); CkStringBuilder_Append(sbPrivKey,"u/NkR6WN96sTy3PC5qEC29hLokMV4/TzmJGAUO+KpK2Z7ylZUd1qMkFngzl50mNs"); CkStringBuilder_Append(sbPrivKey,"GzRX5D/BE+BJcMriCBK4sGIWm9DiK556zvF/Nv0j2cR8BHd2kI0OroYsPKWg7KSW"); CkStringBuilder_Append(sbPrivKey,"0uVoxH7sGNeilVVGJYW7QMBo73OmitDQZvix/XzC6QBOoHxmTctIMzA6K1TW5ECt"); CkStringBuilder_Append(sbPrivKey,"SKABg/KfWR3QdBdxcJCCxI1IkFupyvv3ygzSdEwW6YGVKWPG0eOtKs8SnXmdcjw6"); CkStringBuilder_Append(sbPrivKey,"l9go4en5AgMBAAECggEAB8nsTqalwGIhFw8mbXuhNUFlGuek/arYLD6pv28swwQH"); CkStringBuilder_Append(sbPrivKey,"7v0ZlxFUcCHF+iBl0PsDwZTZQ4ePtgGS6ehoLkWHCzb1lEv5E1YVG5qKNE2UUwRl"); CkStringBuilder_Append(sbPrivKey,"fIyPakO6AzyV/UF3uzq7C+/GuXGNTKZxKewg5yD/DCFvKoCOpxu9u36FyqP/hw0S"); CkStringBuilder_Append(sbPrivKey,"ADVlmp35/zoPDPZzu1j4FiCo0pJ9LwJcHxeJHopNAKDw9k6I4z/grskdgupsGzK2"); CkStringBuilder_Append(sbPrivKey,"BiGiQ/+wmmO68/6Xa6KWfpr1PQ6ODJHgzZsdGCVi6Ebaqlj6BbsYWxP6h3lrsGt+"); CkStringBuilder_Append(sbPrivKey,"LmHBaN2jCD6cDp+lihqFgnm8hfdv0lmbPilp71EDfwKBgQD6U8PBzZtN8yXm5WuS"); CkStringBuilder_Append(sbPrivKey,"NL+/8q5GjNmeTJBSo1gM6Y8vOT4QAE147LbVuVBDwyHPoSrNejePae6Q14PswjBy"); CkStringBuilder_Append(sbPrivKey,"T7B8DZ0OeQyGa3trrFg/ib7Vv4ZMvJqX9+WzBrzZsxTg7oCKHzmCR4vIRItKHH3z"); CkStringBuilder_Append(sbPrivKey,"Wnnhqlo8ic2AZ2O43cdJosbO1wKBgQDe8UODOLu0vnHohOKeUqF3w/ZOB2+83/js"); CkStringBuilder_Append(sbPrivKey,"YyUbSkzsGvHIwTjObuMUFTQvdMZ6IkIyJdfnDZIbvlBSD8tzL5iKFTNCK2nL1i4G"); CkStringBuilder_Append(sbPrivKey,"iFr0CYLaHAlhJ5GEbTrTMDoJeBPerZq83HPrSa/Wb0xO18QTWsoVQPFfPFbbcQyI"); CkStringBuilder_Append(sbPrivKey,"9ryJ2iIDrwKBgQC6kuAefG46ZPVk6K2KZUJdgDUgZC52a75NuW0RAqszmUiGiJM1"); CkStringBuilder_Append(sbPrivKey,"g8ip9tq6BqAWrprGV0c93shusBKlzf5p1LdHXqYmeVY6gbWVhPipMrNHgN5KJ3BZ"); CkStringBuilder_Append(sbPrivKey,"v+w1yNnMsErpcxne2HL2hPjMJTpj3GSLkm2xIlTrNhIyl9ydlr7IRUhENQKBgQCv"); CkStringBuilder_Append(sbPrivKey,"i6HxbXa/90WSJTCcIcxqla8X+dsOCf3jhJ3vQy4Wq5C+1wZ35fCAG8Ifq/+so9Uj"); CkStringBuilder_Append(sbPrivKey,"z5CVqqXlmpF8TFuSs2OVNuRJsg14J4nOMwgLKIIUZAcurQ10DN5I9Kx+UEK1EFXL"); CkStringBuilder_Append(sbPrivKey,"aHsORdNjMfgQDO2jn9WHrr9gkg6CdB2+qyoCEfS+mQKBgBW08lcy9V5RzRWb/v/j"); CkStringBuilder_Append(sbPrivKey,"xsc7ovmgAhCJhDeV7dPbx4HbFeoQJlbA8g1thdcFlcatSGyNDbvNE1GPSd4NhkpR"); CkStringBuilder_Append(sbPrivKey,"Y6Hfv53kdEzjVkEtU8lUdL7HNVJqX7bU7oZlfbYcwxWQ1Gg8C1oLIAyEt71slQtd"); CkStringBuilder_Append(sbPrivKey,"RiNYBRZTQe2F0wxbXnuUqLAw"); privKey = CkPrivateKey_Create(); success = CkPrivateKey_LoadPem(privKey,CkStringBuilder_getAsString(sbPrivKey)); if (success == FALSE) { printf("%s\n",CkPrivateKey_lastErrorText(privKey)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); return; } rsa = CkRsa_Create(); success = CkRsa_ImportPrivateKeyObj(rsa,privKey); if (success == FALSE) { printf("%s\n",CkRsa_lastErrorText(rsa)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); return; } CkRsa_putEncodingMode(rsa,"base64"); b64Signature = CkRsa_signStringENC(rsa,CkStringBuilder_getAsString(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 = CkCert_Create(); success = CkCert_SetFromEncoded(cert,CkStringBuilder_getAsString(sbTppCert)); if (success == FALSE) { printf("%s\n",CkCert_lastErrorText(cert)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); return; } sbSigHdrVal = CkStringBuilder_Create(); CkStringBuilder_Append(sbSigHdrVal,"keyId=\""); CkStringBuilder_Append(sbSigHdrVal,CkCert_serialDecimal(cert)); CkStringBuilder_Append(sbSigHdrVal,"\","); CkStringBuilder_Append(sbSigHdrVal,"algorithm=\"rsa-sha256\","); CkStringBuilder_Append(sbSigHdrVal,"headers=\"date digest x-request-id\","); CkStringBuilder_Append(sbSigHdrVal,"signature=\""); CkStringBuilder_Append(sbSigHdrVal,b64Signature); CkStringBuilder_Append(sbSigHdrVal,"\""); CkHttp_SetRequestHeader(http,"signature",CkStringBuilder_getAsString(sbSigHdrVal)); // ---------------------------------------------------------------- // Add remaining headers... CkHttp_SetRequestHeader(http,"x-ibm-client-id","YOUR_APP_CLIENT_ID"); CkHttp_SetRequestHeader(http,"accept","application/json"); // ---------------------------------------------------------------- // Add our certificate and key for mutual TLS // (provide a registered X509 client certificate during TLS handhake) tlsCert = CkCert_Create(); success = CkCert_LoadFromFile(tlsCert,"qa_data/certs_and_keys/ING/example_client_tls.cer"); if (success == FALSE) { printf("%s\n",CkCert_lastErrorText(tlsCert)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); return; } bdPrivKey = CkBinData_Create(); success = CkBinData_LoadFile(bdPrivKey,"qa_data/certs_and_keys/ING/example_client_tls.key"); if (success == FALSE) { printf("Failed to load example_client_tls.key\n"); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); CkBinData_Dispose(bdPrivKey); return; } // 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 = CkPrivateKey_Create(); success = CkPrivateKey_LoadAnyFormat(tlsPrivKey,bdPrivKey,""); if (success == FALSE) { printf("%s\n",CkPrivateKey_lastErrorText(tlsPrivKey)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(tlsPrivKey); return; } // Associate the private key with the certificate. success = CkCert_SetPrivateKey(tlsCert,tlsPrivKey); if (success == FALSE) { printf("%s\n",CkCert_lastErrorText(tlsCert)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(tlsPrivKey); return; } success = CkHttp_SetSslClientCert(http,tlsCert); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(tlsPrivKey); return; } // ---------------------------------------------------------------- // Finally, send the request... sbResponseBody = CkStringBuilder_Create(); success = CkHttp_QuickGetSb(http,"https://api-sandbox.rabobank.nl/openapi/sandbox/payments/account-information/ais/v3/accounts",sbResponseBody); if (success == FALSE) { printf("%s\n",CkHttp_lastErrorText(http)); printf("%s\n",CkStringBuilder_getAsString(sbResponseBody)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(tlsPrivKey); CkStringBuilder_Dispose(sbResponseBody); return; } jResp = CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,FALSE); printf("Response Body:\n"); printf("%s\n",CkJsonObject_emit(jResp)); respStatusCode = CkHttp_getLastStatus(http); printf("Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { printf("Response Header:\n"); printf("%s\n",CkHttp_lastHeader(http)); printf("Failed.\n"); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(tlsPrivKey); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); return; } // 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 i = 0; count_i = CkJsonObject_SizeOfArray(jResp,"accounts"); while (i < count_i) { CkJsonObject_putI(jResp,i); v_linksAccount = CkJsonObject_stringOf(jResp,"accounts[i]._links.account"); v_linksBalances = CkJsonObject_stringOf(jResp,"accounts[i]._links.balances"); v_linksTransactions = CkJsonObject_stringOf(jResp,"accounts[i]._links.transactions"); currency = CkJsonObject_stringOf(jResp,"accounts[i].currency"); iban = CkJsonObject_stringOf(jResp,"accounts[i].iban"); name = CkJsonObject_stringOf(jResp,"accounts[i].name"); resourceId = CkJsonObject_stringOf(jResp,"accounts[i].resourceId"); status = CkJsonObject_stringOf(jResp,"accounts[i].status"); i = i + 1; } CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbTppCert); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbDigestHdrVal); CkStringBuilder_Dispose(sbStringToSign); CkStringBuilder_Dispose(sbPrivKey); CkPrivateKey_Dispose(privKey); CkRsa_Dispose(rsa); CkCert_Dispose(cert); CkStringBuilder_Dispose(sbSigHdrVal); CkCert_Dispose(tlsCert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(tlsPrivKey); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.