Chilkat Online Tools

C / Zoom API / Search company contacts

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkJsonObject queryParams;
    HCkHttpResponse resp;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *id;
    const char *email;
    const char *first_name;
    const char *last_name;
    const char *presence_status;
    const char *phone_number;
    const char *sip_phone_number;
    const char *extension_number;
    const char *im_group_id;
    const char *im_group_name;
    const char *dept;
    const char *job_title;
    const char *location;
    const char *sip_uri;
    int contact_type;
    int j;
    int count_j;
    const char *country;
    const char *code;
    const char *v_number;
    BOOL verified;
    const char *label;
    int intVal;
    int page_size;
    const char *next_page_token;
    int i;
    int count_i;

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

    http = CkHttp_Create();

    queryParams = CkJsonObject_Create();
    CkJsonObject_UpdateString(queryParams,"search_key","quis officia in reprehenderit");
    CkJsonObject_UpdateString(queryParams,"query_presence_status","quis officia in reprehenderit");
    CkJsonObject_UpdateInt(queryParams,"page_size",1);
    CkJsonObject_UpdateInt(queryParams,"contact_types",1);
    CkJsonObject_UpdateString(queryParams,"next_page_token","quis officia in reprehenderit");

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

    resp = CkHttp_QuickRequestParams(http,"GET","https://api.zoom.us/v2/contacts",queryParams);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        return;
    }

    sbResponseBody = CkStringBuilder_Create();
    CkHttpResponse_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttpResponse_getStatusCode(resp);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttpResponse_header(resp));
        printf("Failed.\n");
        CkHttpResponse_Dispose(resp);
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(queryParams);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

    CkHttpResponse_Dispose(resp);

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

    // {
    //   "page_size": 1,
    //   "next_page_token": " ",
    //   "contacts": [
    //     {
    //       "id": "isds324bdfsf",
    //       "email": "example@example.com",
    //       "first_name": "John",
    //       "last_name": "Doe",
    //       "presence_status": "Offline",
    //       "phone_number": "15550100",
    //       "phone_numbers": [
    //         {
    //           "country": "US",
    //           "code": "+1",
    //           "number": "15550102",
    //           "verified": true,
    //           "label": "Mobile"
    //         }
    //       ],
    //       "sip_phone_number": "11111111",
    //       "direct_numbers": [
    //         111111,
    //         222222
    //       ],
    //       "extension_number": "010",
    //       "im_group_id": "fhksdhfew34hjds",
    //       "im_group_name": "Engineering",
    //       "dept": "Engineering",
    //       "job_title": "Engineer",
    //       "location": "New York",
    //       "sip_uri": "800@aaa.example.com",
    //       "contact_type": 1
    //     }
    //   ]
    // }

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

    page_size = CkJsonObject_IntOf(jResp,"page_size");
    next_page_token = CkJsonObject_stringOf(jResp,"next_page_token");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"contacts");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        id = CkJsonObject_stringOf(jResp,"contacts[i].id");
        email = CkJsonObject_stringOf(jResp,"contacts[i].email");
        first_name = CkJsonObject_stringOf(jResp,"contacts[i].first_name");
        last_name = CkJsonObject_stringOf(jResp,"contacts[i].last_name");
        presence_status = CkJsonObject_stringOf(jResp,"contacts[i].presence_status");
        phone_number = CkJsonObject_stringOf(jResp,"contacts[i].phone_number");
        sip_phone_number = CkJsonObject_stringOf(jResp,"contacts[i].sip_phone_number");
        extension_number = CkJsonObject_stringOf(jResp,"contacts[i].extension_number");
        im_group_id = CkJsonObject_stringOf(jResp,"contacts[i].im_group_id");
        im_group_name = CkJsonObject_stringOf(jResp,"contacts[i].im_group_name");
        dept = CkJsonObject_stringOf(jResp,"contacts[i].dept");
        job_title = CkJsonObject_stringOf(jResp,"contacts[i].job_title");
        location = CkJsonObject_stringOf(jResp,"contacts[i].location");
        sip_uri = CkJsonObject_stringOf(jResp,"contacts[i].sip_uri");
        contact_type = CkJsonObject_IntOf(jResp,"contacts[i].contact_type");
        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"contacts[i].phone_numbers");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            country = CkJsonObject_stringOf(jResp,"contacts[i].phone_numbers[j].country");
            code = CkJsonObject_stringOf(jResp,"contacts[i].phone_numbers[j].code");
            v_number = CkJsonObject_stringOf(jResp,"contacts[i].phone_numbers[j].number");
            verified = CkJsonObject_BoolOf(jResp,"contacts[i].phone_numbers[j].verified");
            label = CkJsonObject_stringOf(jResp,"contacts[i].phone_numbers[j].label");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObject_SizeOfArray(jResp,"contacts[i].direct_numbers");
        while (j < count_j) {
            CkJsonObject_putJ(jResp,j);
            intVal = CkJsonObject_IntOf(jResp,"contacts[i].direct_numbers[j]");
            j = j + 1;
        }

        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkJsonObject_Dispose(queryParams);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -G -d "search_key=quis%20officia%20in%20reprehenderit"
	-d "query_presence_status=quis%20officia%20in%20reprehenderit"
	-d "page_size=1"
	-d "contact_types=1"
	-d "next_page_token=quis%20officia%20in%20reprehenderit"
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/contacts

Postman Collection Item JSON

{
  "name": "Search company contacts",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/contacts?search_key=quis officia in reprehenderit&query_presence_status=quis officia in reprehenderit&page_size=1&contact_types=1&next_page_token=quis officia in reprehenderit",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "contacts"
      ],
      "query": [
        {
          "key": "search_key",
          "value": "quis officia in reprehenderit",
          "description": "(Required) Provide the keyword - either first name, last name or email of the contact whom you have to search for."
        },
        {
          "key": "query_presence_status",
          "value": "quis officia in reprehenderit",
          "description": "Set `query_presence_status` to `true` in order to include the presence status of a contact in the response."
        },
        {
          "key": "page_size",
          "value": "1",
          "description": "The number of records to be returned with a single API call."
        },
        {
          "key": "contact_types",
          "value": "1",
          "description": "A comma-separated list of the type of user contact to query: \n* `1` — A Zoom user. \n* `2` — An auto receptionist. \n* `3` — A common area phone. \n* `4` — A call queue. \n * `5` — A shared line group. \n* `6` — A shared global directory. \n* `7` — A shared office contact. \n\n**Note:** \n* You must have a [phone management role with the \"**View**\" permission](https://support.zoom.us/hc/en-us/articles/360042099012-Using-Zoom-Phone-role-management) to query the `2`, `3`, `4`, `5`, and `7` values. \n* You must provide a valid `search_key` value to query this parameter."
        },
        {
          "key": "next_page_token",
          "value": "quis officia in reprehenderit",
          "description": "The next page token is used to paginate through large result sets. A next page token will be returned whenever the set of available results exceeds the current page size. The expiration period for this token is 15 minutes."
        }
      ]
    },
    "description": "A user under an organization's Zoom account has internal users listed under Company Contacts in the Zoom Client. Use this API to search users that are in the company contacts of a Zoom account. Using the `search_key` query parameter, provide either first name, last name or the email address of the user that you would like to search for. Optionally, set `query_presence_status` to `true` in order to include the presence status of a contact. <br><br>\n\n**Scopes:** `contact:read:admin`, `contact:read`<br>\n\n **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium` "
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200`<br>\nContact returned successfully.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/contacts?search_key=quis officia in reprehenderit&query_presence_status=quis officia in reprehenderit&page_size=1&contact_types=1&next_page_token=quis officia in reprehenderit",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "contacts"
          ],
          "query": [
            {
              "key": "search_key",
              "value": "quis officia in reprehenderit"
            },
            {
              "key": "query_presence_status",
              "value": "quis officia in reprehenderit"
            },
            {
              "key": "page_size",
              "value": "1"
            },
            {
              "key": "contact_types",
              "value": "1"
            },
            {
              "key": "next_page_token",
              "value": "quis officia in reprehenderit"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"page_size\": 1,\n \"next_page_token\": \" \",\n \"contacts\": [\n  {\n   \"id\": \"isds324bdfsf\",\n   \"email\": \"example@example.com\",\n   \"first_name\": \"John\",\n   \"last_name\": \"Doe\",\n   \"presence_status\": \"Offline\",\n   \"phone_number\": \"15550100\",\n   \"phone_numbers\": [\n    {\n     \"country\": \"US\",\n     \"code\": \"+1\",\n     \"number\": \"15550102\",\n     \"verified\": true,\n     \"label\": \"Mobile\"\n    }\n   ],\n   \"sip_phone_number\": \"11111111\",\n   \"direct_numbers\": [\n    111111,\n    222222\n   ],\n   \"extension_number\": \"010\",\n   \"im_group_id\": \"fhksdhfew34hjds\",\n   \"im_group_name\": \"Engineering\",\n   \"dept\": \"Engineering\",\n   \"job_title\": \"Engineer\",\n   \"location\": \"New York\",\n   \"sip_uri\": \"800@aaa.example.com\",\n   \"contact_type\": 1\n  }\n ]\n}"
    }
  ]
}