Chilkat Online Tools

DataFlex / Support API / Show Custom Object

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sKey
    String sTitle
    String sTitle_pluralized
    String sCreated_at
    String sCreated_by_user_id
    String sDescription
    String sRaw_description
    String sRaw_title
    String sRaw_title_pluralized
    String sUpdated_at
    String sUpdated_by_user_id
    String sV_Url
    String sTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Set ComBasicAuth Of hoHttp To True
    Set ComLogin Of hoHttp To "login"
    Set ComPassword Of hoHttp To "password"

    Send ComSetRequestHeader To hoHttp "Accept" "application/json"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://example.zendesk.com/api/v2/custom_objects/:custom_object_key" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

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

    // {
    //   "custom_object": {
    //     "key": "<string>",
    //     "title": "<string>",
    //     "title_pluralized": "<string>",
    //     "created_at": "<dateTime>",
    //     "created_by_user_id": "<string>",
    //     "description": "<string>",
    //     "raw_description": "<string>",
    //     "raw_title": "<string>",
    //     "raw_title_pluralized": "<string>",
    //     "updated_at": "<dateTime>",
    //     "updated_by_user_id": "<string>",
    //     "url": "<string>"
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    Get ComStringOf Of hoJResp "custom_object.key" To sKey
    Get ComStringOf Of hoJResp "custom_object.title" To sTitle
    Get ComStringOf Of hoJResp "custom_object.title_pluralized" To sTitle_pluralized
    Get ComStringOf Of hoJResp "custom_object.created_at" To sCreated_at
    Get ComStringOf Of hoJResp "custom_object.created_by_user_id" To sCreated_by_user_id
    Get ComStringOf Of hoJResp "custom_object.description" To sDescription
    Get ComStringOf Of hoJResp "custom_object.raw_description" To sRaw_description
    Get ComStringOf Of hoJResp "custom_object.raw_title" To sRaw_title
    Get ComStringOf Of hoJResp "custom_object.raw_title_pluralized" To sRaw_title_pluralized
    Get ComStringOf Of hoJResp "custom_object.updated_at" To sUpdated_at
    Get ComStringOf Of hoJResp "custom_object.updated_by_user_id" To sUpdated_by_user_id
    Get ComStringOf Of hoJResp "custom_object.url" To sV_Url


End_Procedure

Curl Command

curl  -u login:password -X GET
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/custom_objects/:custom_object_key

Postman Collection Item JSON

{
  "name": "Show Custom Object",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/custom_objects/:custom_object_key",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "custom_objects",
        ":custom_object_key"
      ],
      "variable": [
        {
          "key": "custom_object_key",
          "value": "<string>"
        }
      ]
    },
    "description": "Returns an object with the specified key\n#### Allowed For\n* Agents\n"
  },
  "response": [
    {
      "name": "Custom Object",
      "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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "custom_objects",
            ":custom_object_key"
          ],
          "variable": [
            {
              "key": "custom_object_key"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"custom_object\": {\n    \"key\": \"<string>\",\n    \"title\": \"<string>\",\n    \"title_pluralized\": \"<string>\",\n    \"created_at\": \"<dateTime>\",\n    \"created_by_user_id\": \"<string>\",\n    \"description\": \"<string>\",\n    \"raw_description\": \"<string>\",\n    \"raw_title\": \"<string>\",\n    \"raw_title_pluralized\": \"<string>\",\n    \"updated_at\": \"<dateTime>\",\n    \"updated_by_user_id\": \"<string>\",\n    \"url\": \"<string>\"\n  }\n}"
    }
  ]
}