Chilkat Online Tools

C / Belvo API Docs / Detail

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *id;
    const char *Value;
    const char *institutionValue;
    const char *collected_atValue;
    const char *categoryValue;
    const char *typeValue;
    const char *nameValue;
    const char *numberValue;
    const char *balanceValue;
    const char *currencyValue;
    const char *bank_product_idValue;
    const char *internal_identificationValue;
    const char *public_identification_nameValue;
    const char *public_identification_valueValue;
    const char *last_accessed_atValue;
    const char *credit_dataValue;
    const char *loan_dataValue;
    const char *funds_dataValue;
    const char *gig_payment_dataValue;

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

    http = CkHttp_Create();

    CkHttp_putBasicAuth(http,TRUE);
    CkHttp_putLogin(http,"{{secretId}}");
    CkHttp_putPassword(http,"{{secretPassword}}");

    sbResponseBody = CkStringBuilder_Create();
    success = CkHttp_QuickGetSb(http,"https://domain.com/api/accounts/:id/",sbResponseBody);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        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);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "id": "<uuid>",
    //   "link": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "institution": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "collected_at": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "category": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "type": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "name": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "number": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "balance": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "currency": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "bank_product_id": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "internal_identification": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "public_identification_name": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "public_identification_value": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "last_accessed_at": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "credit_data": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "loan_data": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "funds_data": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   },
    //   "gig_payment_data": {
    //     "value": "<Error: Too many levels of nesting to fake this schema>"
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    id = CkJsonObject_stringOf(jResp,"id");
    Value = CkJsonObject_stringOf(jResp,"link.value");
    institutionValue = CkJsonObject_stringOf(jResp,"institution.value");
    collected_atValue = CkJsonObject_stringOf(jResp,"collected_at.value");
    categoryValue = CkJsonObject_stringOf(jResp,"category.value");
    typeValue = CkJsonObject_stringOf(jResp,"type.value");
    nameValue = CkJsonObject_stringOf(jResp,"name.value");
    numberValue = CkJsonObject_stringOf(jResp,"number.value");
    balanceValue = CkJsonObject_stringOf(jResp,"balance.value");
    currencyValue = CkJsonObject_stringOf(jResp,"currency.value");
    bank_product_idValue = CkJsonObject_stringOf(jResp,"bank_product_id.value");
    internal_identificationValue = CkJsonObject_stringOf(jResp,"internal_identification.value");
    public_identification_nameValue = CkJsonObject_stringOf(jResp,"public_identification_name.value");
    public_identification_valueValue = CkJsonObject_stringOf(jResp,"public_identification_value.value");
    last_accessed_atValue = CkJsonObject_stringOf(jResp,"last_accessed_at.value");
    credit_dataValue = CkJsonObject_stringOf(jResp,"credit_data.value");
    loan_dataValue = CkJsonObject_stringOf(jResp,"loan_data.value");
    funds_dataValue = CkJsonObject_stringOf(jResp,"funds_data.value");
    gig_payment_dataValue = CkJsonObject_stringOf(jResp,"gig_payment_data.value");


    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -X GET
	-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/accounts/:id/

Postman Collection Item JSON

{
  "name": "Detail",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/accounts/:id/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "accounts",
        ":id",
        ""
      ],
      "variable": [
        {
          "key": "id",
          "value": "consequa",
          "description": "(Required) The `account.id` you want to get detailed information about."
        }
      ]
    },
    "description": "Get the details of a specific account."
  },
  "response": [
    {
      "name": "Ok",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/accounts/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"id\": \"<uuid>\",\n\t\"link\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"institution\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"collected_at\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"category\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"type\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"name\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"number\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"balance\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"currency\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"bank_product_id\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"internal_identification\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"public_identification_name\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"public_identification_value\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"last_accessed_at\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"credit_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"loan_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"funds_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"gig_payment_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t}\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/accounts/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t},\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t}\n]"
    },
    {
      "name": "Too Many Sessions",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/accounts/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t},\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t}\n]"
    }
  ]
}