Chilkat Online Tools

unicodeC / Zoho CRM REST APIs / Job Details

Back to Collection Items

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

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *v_type;
    const wchar_t *moduleId;
    const wchar_t *Api_name;
    const wchar_t *Status;
    const wchar_t *fileName;
    int Added_count;
    int Skipped_count;
    int Updated_count;
    int Total_count;
    const wchar_t *code;
    int j;
    int count_j;
    const wchar_t *api_name;
    int index;
    const wchar_t *format;
    const wchar_t *find_by;
    const wchar_t *module;
    const wchar_t *default_value;
    const wchar_t *status;
    const wchar_t *character_encoding;
    const wchar_t *id;
    const wchar_t *v_Url;
    const wchar_t *Method;
    const wchar_t *Download_url;
    const wchar_t *Id;
    const wchar_t *Name;
    BOOL ignore_empty;
    const wchar_t *operation;
    const wchar_t *created_time;
    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();

    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkHttpW_QuickGetSb(http,L"https://domain.com/crm/bulk/v2.1/write/{{job_id}}",sbResponseBody);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

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

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

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

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

    // {
    //   "status": "COMPLETED",
    //   "character_encoding": "UTF-8",
    //   "resource": [
    //     {
    //       "status": "COMPLETED",
    //       "type": "data",
    //       "module": {
    //         "id": "4150868000000002175",
    //         "api_name": "Leads"
    //       },
    //       "field_mappings": [
    //         {
    //           "api_name": "Owner",
    //           "index": 2,
    //           "format": null,
    //           "find_by": null,
    //           "module": null,
    //           "default_value": null
    //         },
    //         {
    //           "api_name": "Last_Name",
    //           "index": 0,
    //           "format": null,
    //           "find_by": null,
    //           "module": null,
    //           "default_value": null
    //         },
    //         {
    //           "api_name": "Mobile",
    //           "index": 1,
    //           "format": null,
    //           "find_by": null,
    //           "module": null,
    //           "default_value": null
    //         }
    //       ],
    //       "file": {
    //         "status": "COMPLETED",
    //         "name": "Fil2.csv",
    //         "added_count": 9,
    //         "skipped_count": 2,
    //         "updated_count": 0,
    //         "total_count": 11
    //       },
    //       "code": "COMPLETED"
    //     }
    //   ],
    //   "id": "4150868000005350003",
    //   "callback": {
    //     "url": "https://www.zoho.com/",
    //     "method": "post"
    //   },
    //   "result": {
    //     "download_url": "https://download-accl.zoho.com/v2/crm/694902309/bulk-write/4150868000005350003/4150868000005350003.zip"
    //   },
    //   "created_by": {
    //     "id": "4150868000000225013",
    //     "name": "Patricia Boyle"
    //   },
    //   "ignore_empty": true,
    //   "operation": "insert",
    //   "created_time": "2021-05-11T12:38:29+05:30"
    // }

    // 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.

    status = CkJsonObjectW_stringOf(jResp,L"status");
    character_encoding = CkJsonObjectW_stringOf(jResp,L"character_encoding");
    id = CkJsonObjectW_stringOf(jResp,L"id");
    v_Url = CkJsonObjectW_stringOf(jResp,L"callback.url");
    Method = CkJsonObjectW_stringOf(jResp,L"callback.method");
    Download_url = CkJsonObjectW_stringOf(jResp,L"result.download_url");
    Id = CkJsonObjectW_stringOf(jResp,L"created_by.id");
    Name = CkJsonObjectW_stringOf(jResp,L"created_by.name");
    ignore_empty = CkJsonObjectW_BoolOf(jResp,L"ignore_empty");
    operation = CkJsonObjectW_stringOf(jResp,L"operation");
    created_time = CkJsonObjectW_stringOf(jResp,L"created_time");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"resource");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        status = CkJsonObjectW_stringOf(jResp,L"resource[i].status");
        v_type = CkJsonObjectW_stringOf(jResp,L"resource[i].type");
        moduleId = CkJsonObjectW_stringOf(jResp,L"resource[i].module.id");
        Api_name = CkJsonObjectW_stringOf(jResp,L"resource[i].module.api_name");
        Status = CkJsonObjectW_stringOf(jResp,L"resource[i].file.status");
        fileName = CkJsonObjectW_stringOf(jResp,L"resource[i].file.name");
        Added_count = CkJsonObjectW_IntOf(jResp,L"resource[i].file.added_count");
        Skipped_count = CkJsonObjectW_IntOf(jResp,L"resource[i].file.skipped_count");
        Updated_count = CkJsonObjectW_IntOf(jResp,L"resource[i].file.updated_count");
        Total_count = CkJsonObjectW_IntOf(jResp,L"resource[i].file.total_count");
        code = CkJsonObjectW_stringOf(jResp,L"resource[i].code");
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"resource[i].field_mappings");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            api_name = CkJsonObjectW_stringOf(jResp,L"resource[i].field_mappings[j].api_name");
            index = CkJsonObjectW_IntOf(jResp,L"resource[i].field_mappings[j].index");
            format = CkJsonObjectW_stringOf(jResp,L"resource[i].field_mappings[j].format");
            find_by = CkJsonObjectW_stringOf(jResp,L"resource[i].field_mappings[j].find_by");
            module = CkJsonObjectW_stringOf(jResp,L"resource[i].field_mappings[j].module");
            default_value = CkJsonObjectW_stringOf(jResp,L"resource[i].field_mappings[j].default_value");
            j = j + 1;
        }

        i = i + 1;
    }



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

    }

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://domain.com/crm/bulk/v2.1/write/{{job_id}}

Postman Collection Item JSON

{
  "name": "Job Details",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{access-token}}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{api-domain}}/crm/bulk/v2.1/write/{{job_id}}",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "bulk",
        "v2.1",
        "write",
        "{{job_id}}"
      ]
    },
    "description": "To get the details of a bulk write job performed previously."
  },
  "response": [
    {
      "name": "SUCCESS RESPONSE",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/bulk/v2.1/write/4150868000005350003",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "bulk",
            "v2.1",
            "write",
            "4150868000005350003"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:21:37 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "Referrer-Policy",
          "value": "strict-origin"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "Pragma",
          "value": "no-cache"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache"
        },
        {
          "key": "Expires",
          "value": "Thu, 01 Jan 1970 00:00:00 GMT"
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-11T12:57:31+05:30"
        },
        {
          "key": "vary",
          "value": "accept-encoding"
        },
        {
          "key": "Content-Encoding",
          "value": "gzip"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=63072000"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"status\": \"COMPLETED\",\n    \"character_encoding\": \"UTF-8\",\n    \"resource\": [\n        {\n            \"status\": \"COMPLETED\",\n            \"type\": \"data\",\n            \"module\": {\n                \"id\": \"4150868000000002175\",\n                \"api_name\": \"Leads\"\n            },\n            \"field_mappings\": [\n                {\n                    \"api_name\": \"Owner\",\n                    \"index\": 2,\n                    \"format\": null,\n                    \"find_by\": null,\n                    \"module\": null,\n                    \"default_value\": null\n                },\n                {\n                    \"api_name\": \"Last_Name\",\n                    \"index\": 0,\n                    \"format\": null,\n                    \"find_by\": null,\n                    \"module\": null,\n                    \"default_value\": null\n                },\n                {\n                    \"api_name\": \"Mobile\",\n                    \"index\": 1,\n                    \"format\": null,\n                    \"find_by\": null,\n                    \"module\": null,\n                    \"default_value\": null\n                }\n            ],\n            \"file\": {\n                \"status\": \"COMPLETED\",\n                \"name\": \"Fil2.csv\",\n                \"added_count\": 9,\n                \"skipped_count\": 2,\n                \"updated_count\": 0,\n                \"total_count\": 11\n            },\n            \"code\": \"COMPLETED\"\n        }\n    ],\n    \"id\": \"4150868000005350003\",\n    \"callback\": {\n        \"url\": \"https://www.zoho.com/\",\n        \"method\": \"post\"\n    },\n    \"result\": {\n        \"download_url\": \"https://download-accl.zoho.com/v2/crm/694902309/bulk-write/4150868000005350003/4150868000005350003.zip\"\n    },\n    \"created_by\": {\n        \"id\": \"4150868000000225013\",\n        \"name\": \"Patricia Boyle\"\n    },\n    \"ignore_empty\": true,\n    \"operation\": \"insert\",\n    \"created_time\": \"2021-05-11T12:38:29+05:30\"\n}"
    },
    {
      "name": "INVALID_URL_PATTERN",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/bulk/v2.1/writ/4150868000005350003",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "bulk",
            "v2.1",
            "writ",
            "4150868000005350003"
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:29:26 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "131"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "X-Frame-Options",
          "value": "deny"
        },
        {
          "key": "X-Download-Options",
          "value": "noopen"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"code\": \"INVALID_URL_PATTERN\",\n    \"details\": {},\n    \"message\": \"Please check if the URL trying to access is a correct one\",\n    \"status\": \"error\"\n}"
    },
    {
      "name": "INVALID_REQUEST_METHOD",
      "originalRequest": {
        "method": "PUT",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/bulk/v2.1/write/4150868000005350003",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "bulk",
            "v2.1",
            "write",
            "4150868000005350003"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:29:51 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "124"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "X-Frame-Options",
          "value": "deny"
        },
        {
          "key": "X-Download-Options",
          "value": "noopen"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"code\": \"INVALID_REQUEST_METHOD\",\n    \"details\": {},\n    \"message\": \"The http request method type is not a valid one\",\n    \"status\": \"error\"\n}"
    },
    {
      "name": "AUTHENTICATION_FAILURE",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/bulk/v2.1/write/4150868000005350003",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "bulk",
            "v2.1",
            "write",
            "4150868000005350003"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:30:07 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "98"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "Referrer-Policy",
          "value": "strict-origin"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "Pragma",
          "value": "no-cache"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache"
        },
        {
          "key": "Expires",
          "value": "Thu, 01 Jan 1970 00:00:00 GMT"
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "X-Download-Options",
          "value": "noopen"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"code\": \"AUTHENTICATION_FAILURE\",\n    \"details\": {},\n    \"message\": \"Authentication failed\",\n    \"status\": \"error\"\n}"
    },
    {
      "name": "RESOURCE_NOT_FOUND",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/bulk/v2.1/write/415086800000535000",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "bulk",
            "v2.1",
            "write",
            "415086800000535000"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 07:30:33 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "Referrer-Policy",
          "value": "strict-origin"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "Pragma",
          "value": "no-cache"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache"
        },
        {
          "key": "Expires",
          "value": "Thu, 01 Jan 1970 00:00:00 GMT"
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "X-ACCESSTOKEN-RESET",
          "value": "2021-05-11T14:00:30+05:30"
        },
        {
          "key": "vary",
          "value": "accept-encoding"
        },
        {
          "key": "Content-Encoding",
          "value": "gzip"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"status\": \"error\",\n    \"code\": \"RESOURCE_NOT_FOUND\",\n    \"message\": \"The requested resource doesn't exist.\",\n    \"details\": {}\n}"
    },
    {
      "name": "OAUTH_SCOPE_MISMATCH",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/bulk/v2.1/write/4150868000005350003",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "bulk",
            "v2.1",
            "write",
            "4150868000005350003"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Thu, 13 May 2021 08:24:50 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/json;charset=utf-8"
        },
        {
          "key": "Content-Length",
          "value": "113"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "Referrer-Policy",
          "value": "strict-origin"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "Pragma",
          "value": "no-cache"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache"
        },
        {
          "key": "Expires",
          "value": "Thu, 01 Jan 1970 00:00:00 GMT"
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "X-Download-Options",
          "value": "noopen"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"code\": \"OAUTH_SCOPE_MISMATCH\",\n    \"details\": {},\n    \"message\": \"invalid oauth scope to access this URL\",\n    \"status\": \"error\"\n}"
    }
  ]
}