unicodeC / Zoom API / Get user's contact details
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW queryParams;
HCkHttpResponseW resp;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *country;
const wchar_t *code;
const wchar_t *v_number;
BOOL verified;
const wchar_t *label;
int intVal;
const wchar_t *id;
const wchar_t *email;
const wchar_t *first_name;
const wchar_t *last_name;
const wchar_t *presence_status;
const wchar_t *phone_number;
const wchar_t *extension_number;
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();
queryParams = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(queryParams,L"query_presence_status",L"true");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://api.zoom.us/v2/chat/users/me/contacts/:contactId",queryParams);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
return;
}
sbResponseBody = CkStringBuilderW_Create();
CkHttpResponseW_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpResponseW_header(resp));
wprintf(L"Failed.\n");
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
CkHttpResponseW_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "id": "u487547sic45ing",
// "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"
// }
// ],
// "direct_numbers": [
// 111111,
// 222222
// ],
// "extension_number": "010"
// }
// 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.
id = CkJsonObjectW_stringOf(jResp,L"id");
email = CkJsonObjectW_stringOf(jResp,L"email");
first_name = CkJsonObjectW_stringOf(jResp,L"first_name");
last_name = CkJsonObjectW_stringOf(jResp,L"last_name");
presence_status = CkJsonObjectW_stringOf(jResp,L"presence_status");
phone_number = CkJsonObjectW_stringOf(jResp,L"phone_number");
extension_number = CkJsonObjectW_stringOf(jResp,L"extension_number");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"phone_numbers");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
country = CkJsonObjectW_stringOf(jResp,L"phone_numbers[i].country");
code = CkJsonObjectW_stringOf(jResp,L"phone_numbers[i].code");
v_number = CkJsonObjectW_stringOf(jResp,L"phone_numbers[i].number");
verified = CkJsonObjectW_BoolOf(jResp,L"phone_numbers[i].verified");
label = CkJsonObjectW_stringOf(jResp,L"phone_numbers[i].label");
i = i + 1;
}
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"direct_numbers");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
intVal = CkJsonObjectW_IntOf(jResp,L"direct_numbers[i]");
i = i + 1;
}
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(queryParams);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -G -d "query_presence_status=true"
-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/chat/users/me/contacts/:contactId
Postman Collection Item JSON
{
"name": "Get user's contact details",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/chat/users/me/contacts/:contactId?query_presence_status=true",
"host": [
"{{baseUrl}}"
],
"path": [
"chat",
"users",
"me",
"contacts",
":contactId"
],
"query": [
{
"key": "query_presence_status",
"value": "true",
"description": "The presence status of the contact. \nInclude this query parameter with a value of `true` to get the presence status of the contact in the response."
}
],
"variable": [
{
"key": "contactId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user's contact Id or email address. The contact can be either a company contact or an external contact."
}
]
},
"description": "A user under an organization’s Zoom account has internal users listed under Company Contacts in the Zoom Client. A Zoom user can also add another Zoom user as a [contact](https://support.zoom.us/hc/en-us/articles/115004055706-Managing-Contacts). Call this API to get information on a specific contact of the Zoom user.\n\n<p style=\"background-color:#e1f5fe; color:#01579b; padding:8px\"> <b>Note: </b>This API only supports <b>user-managed</b> <a href=\"https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app\">OAuth app</a>.</p><br>\n\n**Scope**: `chat_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 information returned.\n\n\n",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/chat/users/me/contacts/:contactId?query_presence_status=true",
"host": [
"{{baseUrl}}"
],
"path": [
"chat",
"users",
"me",
"contacts",
":contactId"
],
"query": [
{
"key": "query_presence_status",
"value": "true"
}
],
"variable": [
{
"key": "contactId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user's contact Id or email address. The contact can be either a company contact or an external contact."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"id\": \"u487547sic45ing\",\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 \"direct_numbers\": [\n 111111,\n 222222\n ],\n \"extension_number\": \"010\"\n}"
},
{
"name": "**HTTP Status Code:** `400`<br>\nBad request<br>\n**Error Code:** `5301`<br>\nRequest to get the presence status of the chat contact failed.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/chat/users/me/contacts/:contactId?query_presence_status=true",
"host": [
"{{baseUrl}}"
],
"path": [
"chat",
"users",
"me",
"contacts",
":contactId"
],
"query": [
{
"key": "query_presence_status",
"value": "true"
}
],
"variable": [
{
"key": "contactId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user's contact Id or email address. The contact can be either a company contact or an external contact."
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
},
{
"name": "**HTTP Status Code:** `404`<br>\n**Error Code**: `1001`<br>\nUser does not exist: $contactId",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: oauth2",
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/chat/users/me/contacts/:contactId?query_presence_status=true",
"host": [
"{{baseUrl}}"
],
"path": [
"chat",
"users",
"me",
"contacts",
":contactId"
],
"query": [
{
"key": "query_presence_status",
"value": "true"
}
],
"variable": [
{
"key": "contactId",
"value": "quis officia in reprehenderit",
"description": "(Required) The user's contact Id or email address. The contact can be either a company contact or an external contact."
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}