Chilkat Online Tools

unicodeC / Support API / Show Many Custom Object Records

Back to Collection Items

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

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW queryParams;
    HCkHttpResponseW resp;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *name;
    const wchar_t *created_at;
    const wchar_t *created_by_user_id;
    const wchar_t *Voluptate571;
    const wchar_t *Aute_e;
    const wchar_t *Nostrud_6f;
    const wchar_t *custom_object_key;
    const wchar_t *external_id;
    const wchar_t *id;
    const wchar_t *updated_at;
    const wchar_t *updated_by_user_id;
    const wchar_t *url;
    const wchar_t *Eu4;
    const wchar_t *count;
    const wchar_t *next_page;
    const wchar_t *previous_page;
    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"login");
    CkHttpW_putPassword(http,L"password");

    queryParams = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(queryParams,L"ids",L"<string>");
    CkJsonObjectW_UpdateString(queryParams,L"ids",L"<string>");

    CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");

    resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://example.zendesk.com/api/v2/custom_objects/:custom_object_key/records/show_many",queryParams);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        return;
    }

    sbResponseBody = CkStringBuilderW_Create();
    CkHttpResponseW_GetBodySb(resp,sbResponseBody);

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

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

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

    CkHttpResponseW_Dispose(resp);

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

    // {
    //   "count": "<integer>",
    //   "custom_object_records": [
    //     {
    //       "name": "<string>",
    //       "created_at": "<dateTime>",
    //       "created_by_user_id": "<string>",
    //       "custom_object_fields": {
    //         "voluptate571": "<string>",
    //         "aute_e": "<string>",
    //         "nostrud_6f": "<string>"
    //       },
    //       "custom_object_key": "<string>",
    //       "external_id": "<string>",
    //       "id": "<string>",
    //       "updated_at": "<dateTime>",
    //       "updated_by_user_id": "<string>",
    //       "url": "<string>"
    //     },
    //     {
    //       "name": "<string>",
    //       "created_at": "<dateTime>",
    //       "created_by_user_id": "<string>",
    //       "custom_object_fields": {
    //         "eu4": "<string>"
    //       },
    //       "custom_object_key": "<string>",
    //       "external_id": "<string>",
    //       "id": "<string>",
    //       "updated_at": "<dateTime>",
    //       "updated_by_user_id": "<string>",
    //       "url": "<string>"
    //     }
    //   ],
    //   "next_page": "<string>",
    //   "previous_page": "<string>"
    // }

    // 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");
    next_page = CkJsonObjectW_stringOf(jResp,L"next_page");
    previous_page = CkJsonObjectW_stringOf(jResp,L"previous_page");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"custom_object_records");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        name = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].name");
        created_at = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].created_at");
        created_by_user_id = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].created_by_user_id");
        Voluptate571 = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].custom_object_fields.voluptate571");
        Aute_e = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].custom_object_fields.aute_e");
        Nostrud_6f = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].custom_object_fields.nostrud_6f");
        custom_object_key = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].custom_object_key");
        external_id = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].external_id");
        id = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].id");
        updated_at = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].updated_at");
        updated_by_user_id = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].updated_by_user_id");
        url = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].url");
        Eu4 = CkJsonObjectW_stringOf(jResp,L"custom_object_records[i].custom_object_fields.eu4");
        i = i + 1;
    }



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

    }

Curl Command

curl  -u login:password -G -d "ids=%3Cstring%3E"
	-d "ids=%3Cstring%3E"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/custom_objects/:custom_object_key/records/show_many

Postman Collection Item JSON

{
  "name": "Show Many Custom Object Records",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/custom_objects/:custom_object_key/records/show_many?ids=<string>&ids=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "custom_objects",
        ":custom_object_key",
        "records",
        "show_many"
      ],
      "query": [
        {
          "key": "ids",
          "value": "<string>",
          "description": "(Required) Array of ids to retieve"
        },
        {
          "key": "ids",
          "value": "<string>",
          "description": "(Required) Array of ids to retieve"
        }
      ],
      "variable": [
        {
          "key": "custom_object_key",
          "value": "<string>"
        }
      ]
    },
    "description": "List multiple custom object records by their ids\n#### Allowed For\n* Everyone"
  },
  "response": [
    {
      "name": "Success response",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/custom_objects/:custom_object_key/records/show_many?ids=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "custom_objects",
            ":custom_object_key",
            "records",
            "show_many"
          ],
          "query": [
            {
              "key": "ids",
              "value": "<string>",
              "description": "(Required) Array of ids to retieve"
            }
          ],
          "variable": [
            {
              "key": "custom_object_key"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"count\": \"<integer>\",\n  \"custom_object_records\": [\n    {\n      \"name\": \"<string>\",\n      \"created_at\": \"<dateTime>\",\n      \"created_by_user_id\": \"<string>\",\n      \"custom_object_fields\": {\n        \"voluptate571\": \"<string>\",\n        \"aute_e\": \"<string>\",\n        \"nostrud_6f\": \"<string>\"\n      },\n      \"custom_object_key\": \"<string>\",\n      \"external_id\": \"<string>\",\n      \"id\": \"<string>\",\n      \"updated_at\": \"<dateTime>\",\n      \"updated_by_user_id\": \"<string>\",\n      \"url\": \"<string>\"\n    },\n    {\n      \"name\": \"<string>\",\n      \"created_at\": \"<dateTime>\",\n      \"created_by_user_id\": \"<string>\",\n      \"custom_object_fields\": {\n        \"eu4\": \"<string>\"\n      },\n      \"custom_object_key\": \"<string>\",\n      \"external_id\": \"<string>\",\n      \"id\": \"<string>\",\n      \"updated_at\": \"<dateTime>\",\n      \"updated_by_user_id\": \"<string>\",\n      \"url\": \"<string>\"\n    }\n  ],\n  \"next_page\": \"<string>\",\n  \"previous_page\": \"<string>\"\n}"
    }
  ]
}