Chilkat Online Tools

Foxpro / Support API / List Custom Object Records

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loQueryParams
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcName
LOCAL lcCreated_at
LOCAL lcCreated_by_user_id
LOCAL lcVoluptate571
LOCAL lcAute_e
LOCAL lcNostrud_6f
LOCAL lcCustom_object_key
LOCAL lcExternal_id
LOCAL lcId
LOCAL lcUpdated_at
LOCAL lcUpdated_by_user_id
LOCAL lcUrl
LOCAL lcEu4
LOCAL lcCount
LOCAL lcNext_page
LOCAL lcPrevious_page
LOCAL i
LOCAL lnCount_i

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

loHttp.BasicAuth = 1
loHttp.Login = "login"
loHttp.Password = "password"

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loQueryParams = CreateObject('Chilkat.JsonObject')
loQueryParams.UpdateString("external_ids[]","<string>")
loQueryParams.UpdateString("external_ids[]","<string>")

loHttp.SetRequestHeader("Accept","application/json")

loResp = loHttp.QuickRequestParams("GET","https://example.zendesk.com/api/v2/custom_objects/:custom_object_key/records",loQueryParams)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loQueryParams
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loQueryParams
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* 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

lcCount = loJResp.StringOf("count")
lcNext_page = loJResp.StringOf("next_page")
lcPrevious_page = loJResp.StringOf("previous_page")
i = 0
lnCount_i = loJResp.SizeOfArray("custom_object_records")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcName = loJResp.StringOf("custom_object_records[i].name")
    lcCreated_at = loJResp.StringOf("custom_object_records[i].created_at")
    lcCreated_by_user_id = loJResp.StringOf("custom_object_records[i].created_by_user_id")
    lcVoluptate571 = loJResp.StringOf("custom_object_records[i].custom_object_fields.voluptate571")
    lcAute_e = loJResp.StringOf("custom_object_records[i].custom_object_fields.aute_e")
    lcNostrud_6f = loJResp.StringOf("custom_object_records[i].custom_object_fields.nostrud_6f")
    lcCustom_object_key = loJResp.StringOf("custom_object_records[i].custom_object_key")
    lcExternal_id = loJResp.StringOf("custom_object_records[i].external_id")
    lcId = loJResp.StringOf("custom_object_records[i].id")
    lcUpdated_at = loJResp.StringOf("custom_object_records[i].updated_at")
    lcUpdated_by_user_id = loJResp.StringOf("custom_object_records[i].updated_by_user_id")
    lcUrl = loJResp.StringOf("custom_object_records[i].url")
    lcEu4 = loJResp.StringOf("custom_object_records[i].custom_object_fields.eu4")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loQueryParams
RELEASE loSbResponseBody
RELEASE loJResp

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}"
    }
  ]
}