Chilkat Online Tools

TCL / Support API / Show Many Custom Object Records

Back to Collection Items

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]

CkHttp_put_BasicAuth $http 1
CkHttp_put_Login $http "login"
CkHttp_put_Password $http "password"

set queryParams [new_CkJsonObject]

CkJsonObject_UpdateString $queryParams "ids" "<string>"
CkJsonObject_UpdateString $queryParams "ids" "<string>"

CkHttp_SetRequestHeader $http "Accept" "application/json"

# resp is a CkHttpResponse
set resp [CkHttp_QuickRequestParams $http "GET" "https://example.zendesk.com/api/v2/custom_objects/:custom_object_key/records/show_many" $queryParams]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $queryParams
    exit
}

set sbResponseBody [new_CkStringBuilder]

CkHttpResponse_GetBodySb $resp $sbResponseBody

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

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

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    delete_CkJsonObject $queryParams
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

delete_CkHttpResponse $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

set count [CkJsonObject_stringOf $jResp "count"]
set next_page [CkJsonObject_stringOf $jResp "next_page"]
set previous_page [CkJsonObject_stringOf $jResp "previous_page"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "custom_object_records"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set name [CkJsonObject_stringOf $jResp "custom_object_records[i].name"]
    set created_at [CkJsonObject_stringOf $jResp "custom_object_records[i].created_at"]
    set created_by_user_id [CkJsonObject_stringOf $jResp "custom_object_records[i].created_by_user_id"]
    set Voluptate571 [CkJsonObject_stringOf $jResp "custom_object_records[i].custom_object_fields.voluptate571"]
    set Aute_e [CkJsonObject_stringOf $jResp "custom_object_records[i].custom_object_fields.aute_e"]
    set Nostrud_6f [CkJsonObject_stringOf $jResp "custom_object_records[i].custom_object_fields.nostrud_6f"]
    set custom_object_key [CkJsonObject_stringOf $jResp "custom_object_records[i].custom_object_key"]
    set external_id [CkJsonObject_stringOf $jResp "custom_object_records[i].external_id"]
    set id [CkJsonObject_stringOf $jResp "custom_object_records[i].id"]
    set updated_at [CkJsonObject_stringOf $jResp "custom_object_records[i].updated_at"]
    set updated_by_user_id [CkJsonObject_stringOf $jResp "custom_object_records[i].updated_by_user_id"]
    set url [CkJsonObject_stringOf $jResp "custom_object_records[i].url"]
    set Eu4 [CkJsonObject_stringOf $jResp "custom_object_records[i].custom_object_fields.eu4"]
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkJsonObject $queryParams
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $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}"
    }
  ]
}