unicodeCpp / Support API / List Custom Object Records
Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
bool success;
http.put_BasicAuth(true);
http.put_Login(L"login");
http.put_Password(L"password");
CkJsonObjectW queryParams;
queryParams.UpdateString(L"external_ids[]",L"<string>");
queryParams.UpdateString(L"external_ids[]",L"<string>");
http.SetRequestHeader(L"Accept",L"application/json");
CkHttpResponseW *resp = http.QuickRequestParams(L"GET",L"https://example.zendesk.com/api/v2/custom_objects/:custom_object_key/records",queryParams);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
CkStringBuilderW sbResponseBody;
resp->GetBodySb(sbResponseBody);
CkJsonObjectW jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",jResp.emit());
int respStatusCode = resp->get_StatusCode();
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",resp->header());
wprintf(L"Failed.\n");
delete resp;
return;
}
delete 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.
const wchar_t *name = 0;
const wchar_t *created_at = 0;
const wchar_t *created_by_user_id = 0;
const wchar_t *Voluptate571 = 0;
const wchar_t *Aute_e = 0;
const wchar_t *Nostrud_6f = 0;
const wchar_t *custom_object_key = 0;
const wchar_t *external_id = 0;
const wchar_t *id = 0;
const wchar_t *updated_at = 0;
const wchar_t *updated_by_user_id = 0;
const wchar_t *url = 0;
const wchar_t *Eu4 = 0;
const wchar_t *count = jResp.stringOf(L"count");
const wchar_t *next_page = jResp.stringOf(L"next_page");
const wchar_t *previous_page = jResp.stringOf(L"previous_page");
int i = 0;
int count_i = jResp.SizeOfArray(L"custom_object_records");
while (i < count_i) {
jResp.put_I(i);
name = jResp.stringOf(L"custom_object_records[i].name");
created_at = jResp.stringOf(L"custom_object_records[i].created_at");
created_by_user_id = jResp.stringOf(L"custom_object_records[i].created_by_user_id");
Voluptate571 = jResp.stringOf(L"custom_object_records[i].custom_object_fields.voluptate571");
Aute_e = jResp.stringOf(L"custom_object_records[i].custom_object_fields.aute_e");
Nostrud_6f = jResp.stringOf(L"custom_object_records[i].custom_object_fields.nostrud_6f");
custom_object_key = jResp.stringOf(L"custom_object_records[i].custom_object_key");
external_id = jResp.stringOf(L"custom_object_records[i].external_id");
id = jResp.stringOf(L"custom_object_records[i].id");
updated_at = jResp.stringOf(L"custom_object_records[i].updated_at");
updated_by_user_id = jResp.stringOf(L"custom_object_records[i].updated_by_user_id");
url = jResp.stringOf(L"custom_object_records[i].url");
Eu4 = jResp.stringOf(L"custom_object_records[i].custom_object_fields.eu4");
i = i + 1;
}
}
Curl Command
curl -u login:password -G -d "external_ids[]=%3Cstring%3E"
-d "external_ids[]=%3Cstring%3E"
-H "Accept: application/json"
https://example.zendesk.com/api/v2/custom_objects/:custom_object_key/records
Postman Collection Item JSON
{
"name": "List Custom Object Records",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/custom_objects/:custom_object_key/records?external_ids[]=<string>&external_ids[]=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"custom_objects",
":custom_object_key",
"records"
],
"query": [
{
"key": "external_ids[]",
"value": "<string>",
"description": "Optional parameter to search records by external ids. If one or more ids are specified, only matching records will be returned. These ids are unique and case sencitive"
},
{
"key": "external_ids[]",
"value": "<string>",
"description": "Optional parameter to search records by external ids. If one or more ids are specified, only matching records will be returned. These ids are unique and case sencitive"
}
],
"variable": [
{
"key": "custom_object_key",
"value": "<string>"
}
]
},
"description": "Lists all undeleted custom object records for the specified object\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?external_ids[]=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"custom_objects",
":custom_object_key",
"records"
],
"query": [
{
"key": "external_ids[]",
"value": "<string>",
"description": "Optional parameter to search records by external ids. If one or more ids are specified, only matching records will be returned. These ids are unique and case sencitive"
}
],
"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}"
}
]
}