Chilkat Online Tools

unicodeCpp / Support API / Show Organization

Back to Collection Items

#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.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");

    http.SetRequestHeader(L"Accept",L"application/json");

    CkStringBuilderW sbResponseBody;
    success = http.QuickGetSb(L"https://example.zendesk.com/api/v2/organizations/:organization_id",sbResponseBody);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

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

    int respStatusCode = http.get_LastStatus();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",http.lastHeader());
        wprintf(L"Failed.\n");
        return;
    }

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

    // {
    //   "organization": {
    //     "created_at": "<string>",
    //     "details": "<string>",
    //     "domain_names": [
    //       "<string>",
    //       "<string>"
    //     ],
    //     "external_id": "<string>",
    //     "group_id": "<integer>",
    //     "id": "<integer>",
    //     "name": "<string>",
    //     "notes": "<string>",
    //     "organization_fields": {
    //       "fugiat5_0": "<string>",
    //       "exercitation_039": "<string>",
    //       "laboris_60": "<string>"
    //     },
    //     "shared_comments": "<boolean>",
    //     "shared_tickets": "<boolean>",
    //     "tags": [
    //       "<string>",
    //       "<string>"
    //     ],
    //     "updated_at": "<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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    const wchar_t *strVal = 0;

    const wchar_t *Created_at = jResp.stringOf(L"organization.created_at");
    const wchar_t *Details = jResp.stringOf(L"organization.details");
    const wchar_t *External_id = jResp.stringOf(L"organization.external_id");
    const wchar_t *Group_id = jResp.stringOf(L"organization.group_id");
    const wchar_t *Id = jResp.stringOf(L"organization.id");
    const wchar_t *Name = jResp.stringOf(L"organization.name");
    const wchar_t *Notes = jResp.stringOf(L"organization.notes");
    const wchar_t *Fugiat5_0 = jResp.stringOf(L"organization.organization_fields.fugiat5_0");
    const wchar_t *Exercitation_039 = jResp.stringOf(L"organization.organization_fields.exercitation_039");
    const wchar_t *Laboris_60 = jResp.stringOf(L"organization.organization_fields.laboris_60");
    const wchar_t *Shared_comments = jResp.stringOf(L"organization.shared_comments");
    const wchar_t *Shared_tickets = jResp.stringOf(L"organization.shared_tickets");
    const wchar_t *Updated_at = jResp.stringOf(L"organization.updated_at");
    const wchar_t *v_Url = jResp.stringOf(L"organization.url");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"organization.domain_names");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf(L"organization.domain_names[i]");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"organization.tags");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf(L"organization.tags[i]");
        i = i + 1;
    }
    }

Curl Command

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

Postman Collection Item JSON

{
  "name": "Show Organization",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/organizations/:organization_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "organizations",
        ":organization_id"
      ],
      "variable": [
        {
          "key": "organization_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "#### Allowed For\n\n* Admins\n* Agents\n"
  },
  "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/organizations/:organization_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "organizations",
            ":organization_id"
          ],
          "variable": [
            {
              "key": "organization_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"organization\": {\n    \"created_at\": \"<string>\",\n    \"details\": \"<string>\",\n    \"domain_names\": [\n      \"<string>\",\n      \"<string>\"\n    ],\n    \"external_id\": \"<string>\",\n    \"group_id\": \"<integer>\",\n    \"id\": \"<integer>\",\n    \"name\": \"<string>\",\n    \"notes\": \"<string>\",\n    \"organization_fields\": {\n      \"fugiat5_0\": \"<string>\",\n      \"exercitation_039\": \"<string>\",\n      \"laboris_60\": \"<string>\"\n    },\n    \"shared_comments\": \"<boolean>\",\n    \"shared_tickets\": \"<boolean>\",\n    \"tags\": [\n      \"<string>\",\n      \"<string>\"\n    ],\n    \"updated_at\": \"<string>\",\n    \"url\": \"<string>\"\n  }\n}"
    }
  ]
}