Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Tcl Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Tcl) Rabobank GET /v3/accounts

Demonstrates 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

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set http [new_CkHttp]

# 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.
set jsonToken [new_CkJsonObject]

set success [CkJsonObject_LoadFile $jsonToken "qa_data/tokens/rabobank.json"]
if {$success == 0} then {
    puts [CkJsonObject_lastErrorText $jsonToken]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    exit
}

# This adds the "authorization: Bearer REPLACE_BEARER_TOKEN" header.
CkHttp_put_AuthToken $http [CkJsonObject_stringOf $jsonToken "access_token"]

# This is the TTP Signature certificate: The certificate used for signing the request.
set sbTppCert [new_CkStringBuilder]

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.
set crypt [new_CkCrypt2]

set xRequestId [CkCrypt2_generateUuid $crypt]
CkHttp_SetRequestHeader $http "x-request-id" $xRequestId

# ----------------------------------------------------------------
# Date header...
set dt [new_CkDateTime]

CkDateTime_SetFromCurrentSystemTime $dt
set dateHdrVal [CkDateTime_getAsRfc822 $dt 0]
# The desire date/time format is the "RFC822" format.
CkHttp_SetRequestHeader $http "Date" $dateHdrVal

# ----------------------------------------------------------------
# Digest header...
CkCrypt2_put_HashAlgorithm $crypt "SHA256"
CkCrypt2_put_EncodingMode $crypt "base64"
# A GET request has no HTTP request body.  Therefore the payload is the empty string.
set payload ""
set payloadDigest [CkCrypt2_hashStringENC $crypt $payload]
set sbDigestHdrVal [new_CkStringBuilder]

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

set sbStringToSign [new_CkStringBuilder]

CkStringBuilder_Append $sbStringToSign "date: "
CkStringBuilder_AppendLine $sbStringToSign $dateHdrVal 0
CkStringBuilder_Append $sbStringToSign "digest: "
CkStringBuilder_AppendLine $sbStringToSign [CkStringBuilder_getAsString $sbDigestHdrVal] 0
CkStringBuilder_Append $sbStringToSign "x-request-id: "
CkStringBuilder_Append $sbStringToSign $xRequestId

# ----------------------------------------------------------------
# Sign with our private key...
set sbPrivKey [new_CkStringBuilder]

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"

set privKey [new_CkPrivateKey]

set success [CkPrivateKey_LoadPem $privKey [CkStringBuilder_getAsString $sbPrivKey]]
if {$success == 0} then {
    puts [CkPrivateKey_lastErrorText $privKey]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    exit
}

set rsa [new_CkRsa]

set success [CkRsa_ImportPrivateKeyObj $rsa $privKey]
if {$success == 0} then {
    puts [CkRsa_lastErrorText $rsa]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    exit
}

CkRsa_put_EncodingMode $rsa "base64"
set 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. 
set cert [new_CkCert]

set success [CkCert_SetFromEncoded $cert [CkStringBuilder_getAsString $sbTppCert]]
if {$success == 0} then {
    puts [CkCert_lastErrorText $cert]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    exit
}

set sbSigHdrVal [new_CkStringBuilder]

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)

set tlsCert [new_CkCert]

set success [CkCert_LoadFromFile $tlsCert "qa_data/certs_and_keys/ING/example_client_tls.cer"]
if {$success == 0} then {
    puts [CkCert_lastErrorText $tlsCert]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    delete_CkStringBuilder $sbSigHdrVal
    delete_CkCert $tlsCert
    exit
}

set bdPrivKey [new_CkBinData]

set success [CkBinData_LoadFile $bdPrivKey "qa_data/certs_and_keys/ING/example_client_tls.key"]
if {$success == 0} then {
    puts "Failed to load example_client_tls.key"
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    delete_CkStringBuilder $sbSigHdrVal
    delete_CkCert $tlsCert
    delete_CkBinData $bdPrivKey
    exit
}

# 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.

set tlsPrivKey [new_CkPrivateKey]

set success [CkPrivateKey_LoadAnyFormat $tlsPrivKey $bdPrivKey ""]
if {$success == 0} then {
    puts [CkPrivateKey_lastErrorText $tlsPrivKey]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    delete_CkStringBuilder $sbSigHdrVal
    delete_CkCert $tlsCert
    delete_CkBinData $bdPrivKey
    delete_CkPrivateKey $tlsPrivKey
    exit
}

# Associate the private key with the certificate.
set success [CkCert_SetPrivateKey $tlsCert $tlsPrivKey]
if {$success == 0} then {
    puts [CkCert_lastErrorText $tlsCert]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    delete_CkStringBuilder $sbSigHdrVal
    delete_CkCert $tlsCert
    delete_CkBinData $bdPrivKey
    delete_CkPrivateKey $tlsPrivKey
    exit
}

set success [CkHttp_SetSslClientCert $http $tlsCert]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    delete_CkStringBuilder $sbSigHdrVal
    delete_CkCert $tlsCert
    delete_CkBinData $bdPrivKey
    delete_CkPrivateKey $tlsPrivKey
    exit
}

# ----------------------------------------------------------------
# Finally, send the request...

set sbResponseBody [new_CkStringBuilder]

set success [CkHttp_QuickGetSb $http "https://api-sandbox.rabobank.nl/openapi/sandbox/payments/account-information/ais/v3/accounts" $sbResponseBody]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    puts [CkStringBuilder_getAsString $sbResponseBody]
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    delete_CkStringBuilder $sbSigHdrVal
    delete_CkCert $tlsCert
    delete_CkBinData $bdPrivKey
    delete_CkPrivateKey $tlsPrivKey
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttp_get_LastStatus $http]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttp_lastHeader $http]
    puts "Failed."
    delete_CkHttp $http
    delete_CkJsonObject $jsonToken
    delete_CkStringBuilder $sbTppCert
    delete_CkCrypt2 $crypt
    delete_CkDateTime $dt
    delete_CkStringBuilder $sbDigestHdrVal
    delete_CkStringBuilder $sbStringToSign
    delete_CkStringBuilder $sbPrivKey
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkCert $cert
    delete_CkStringBuilder $sbSigHdrVal
    delete_CkCert $tlsCert
    delete_CkBinData $bdPrivKey
    delete_CkPrivateKey $tlsPrivKey
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

# 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

set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "accounts"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set v_linksAccount [CkJsonObject_stringOf $jResp "accounts[i]._links.account"]
    set v_linksBalances [CkJsonObject_stringOf $jResp "accounts[i]._links.balances"]
    set v_linksTransactions [CkJsonObject_stringOf $jResp "accounts[i]._links.transactions"]
    set currency [CkJsonObject_stringOf $jResp "accounts[i].currency"]
    set iban [CkJsonObject_stringOf $jResp "accounts[i].iban"]
    set name [CkJsonObject_stringOf $jResp "accounts[i].name"]
    set resourceId [CkJsonObject_stringOf $jResp "accounts[i].resourceId"]
    set status [CkJsonObject_stringOf $jResp "accounts[i].status"]
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkJsonObject $jsonToken
delete_CkStringBuilder $sbTppCert
delete_CkCrypt2 $crypt
delete_CkDateTime $dt
delete_CkStringBuilder $sbDigestHdrVal
delete_CkStringBuilder $sbStringToSign
delete_CkStringBuilder $sbPrivKey
delete_CkPrivateKey $privKey
delete_CkRsa $rsa
delete_CkCert $cert
delete_CkStringBuilder $sbSigHdrVal
delete_CkCert $tlsCert
delete_CkBinData $bdPrivKey
delete_CkPrivateKey $tlsPrivKey
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.