Chilkat Online Tools

unicodeC / Belvo API Docs / List

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *Value;
    const wchar_t *institutionValue;
    const wchar_t *collected_atValue;
    const wchar_t *categoryValue;
    const wchar_t *typeValue;
    const wchar_t *nameValue;
    const wchar_t *numberValue;
    const wchar_t *balanceValue;
    const wchar_t *currencyValue;
    const wchar_t *bank_product_idValue;
    const wchar_t *internal_identificationValue;
    const wchar_t *public_identification_nameValue;
    const wchar_t *public_identification_valueValue;
    const wchar_t *last_accessed_atValue;
    const wchar_t *credit_dataValue;
    const wchar_t *loan_dataValue;
    const wchar_t *funds_dataValue;
    const wchar_t *gig_payment_dataValue;
    const wchar_t *count;
    const wchar_t *v_next;
    const wchar_t *previous;
    int i;
    int count_i;

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

    http = CkHttpW_Create();

    CkHttpW_putBasicAuth(http,TRUE);
    CkHttpW_putLogin(http,L"{{secretId}}");
    CkHttpW_putPassword(http,L"{{secretPassword}}");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkHttpW_QuickGetSb(http,L"https://domain.com/api/accounts/",sbResponseBody);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",CkJsonObjectW_emit(jResp));

    respStatusCode = CkHttpW_getLastStatus(http);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpW_lastHeader(http));
        wprintf(L"Failed.\n");
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

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

    // {
    //   "count": "<integer>",
    //   "next": "<string>",
    //   "previous": "<string>",
    //   "results": [
    //     {
    //       "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>"
    //       }
    //     },
    //     {
    //       "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.

    count = CkJsonObjectW_stringOf(jResp,L"count");
    v_next = CkJsonObjectW_stringOf(jResp,L"next");
    previous = CkJsonObjectW_stringOf(jResp,L"previous");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"results");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        Value = CkJsonObjectW_stringOf(jResp,L"results[i].link.value");
        institutionValue = CkJsonObjectW_stringOf(jResp,L"results[i].institution.value");
        collected_atValue = CkJsonObjectW_stringOf(jResp,L"results[i].collected_at.value");
        categoryValue = CkJsonObjectW_stringOf(jResp,L"results[i].category.value");
        typeValue = CkJsonObjectW_stringOf(jResp,L"results[i].type.value");
        nameValue = CkJsonObjectW_stringOf(jResp,L"results[i].name.value");
        numberValue = CkJsonObjectW_stringOf(jResp,L"results[i].number.value");
        balanceValue = CkJsonObjectW_stringOf(jResp,L"results[i].balance.value");
        currencyValue = CkJsonObjectW_stringOf(jResp,L"results[i].currency.value");
        bank_product_idValue = CkJsonObjectW_stringOf(jResp,L"results[i].bank_product_id.value");
        internal_identificationValue = CkJsonObjectW_stringOf(jResp,L"results[i].internal_identification.value");
        public_identification_nameValue = CkJsonObjectW_stringOf(jResp,L"results[i].public_identification_name.value");
        public_identification_valueValue = CkJsonObjectW_stringOf(jResp,L"results[i].public_identification_value.value");
        last_accessed_atValue = CkJsonObjectW_stringOf(jResp,L"results[i].last_accessed_at.value");
        credit_dataValue = CkJsonObjectW_stringOf(jResp,L"results[i].credit_data.value");
        loan_dataValue = CkJsonObjectW_stringOf(jResp,L"results[i].loan_data.value");
        funds_dataValue = CkJsonObjectW_stringOf(jResp,L"results[i].funds_data.value");
        gig_payment_dataValue = CkJsonObjectW_stringOf(jResp,L"results[i].gig_payment_data.value");
        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }

Curl Command

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

Postman Collection Item JSON

{
  "name": "List",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/accounts/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "accounts",
        ""
      ],
      "query": [
        {
          "key": "page",
          "value": "1",
          "description": "A page number within the paginated result set.",
          "disabled": true
        }
      ]
    },
    "description": "Get a paginated list of all existing accounts in your Belvo account. We return up to 100 results per page.\n\n**Filterable fields**\n\nPlease see the table below for an alphabetized list of fields that you can filter your responses by. For more information on how to use filters, see our [Filtering responses](https://developers.belvo.com/docs/searching-and-filtering) article.\n\n|Field| Available Filters|\n|---|---|\n|`balance__available`|`=`, `gt`, `gte`, `lt`, `lte`, `range`|\n|`balance__current`|`=`, `gt`, `gte`, `lt`, `lte`, `range`|\n|`bank_product_id`|`=`|\n|`category`|`=`, `in`|\n|`collected_at`|`=`, `gt`, `gte`, `lt`, `lte`, `range`|\n|`currency`|`=`, `in`|\n|`id`|`=`, `in`|\n|`institution`|`=`, `in`|\n|`internal_identification`|`=`|\n|`link`|`=`, `in`|\n|`name`|`=`, `icontains`|\n|`number`|`=`, `in`|\n|`public_identification_name`|`=`|\n|`public_identification_value`|`=`|\n|`type`|`=`, `in`|"
  },
  "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?page=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts"
          ],
          "query": [
            {
              "key": "page",
              "value": "<integer>"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"count\": \"<integer>\",\n\t\"next\": \"<string>\",\n\t\"previous\": \"<string>\",\n\t\"results\": [\n\t\t{\n\t\t\t\"link\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"institution\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"collected_at\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"category\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"type\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"name\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"number\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"balance\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"currency\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"bank_product_id\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"internal_identification\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"public_identification_name\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"public_identification_value\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"last_accessed_at\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"credit_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"loan_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"funds_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"gig_payment_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"link\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"institution\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"collected_at\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"category\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"type\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"name\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"number\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"balance\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"currency\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"bank_product_id\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"internal_identification\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"public_identification_name\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"public_identification_value\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"last_accessed_at\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"credit_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"loan_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"funds_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t\"gig_payment_data\": {\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t}\n\t\t}\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?page=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts"
          ],
          "query": [
            {
              "key": "page",
              "value": "<integer>"
            }
          ]
        }
      },
      "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]"
    }
  ]
}