List users, returning a maximum of 100 users per page.
curl https://subdomain.zendesk.com/api/v2/users.json \
-u zendesk_email/token:zendesk_api_token
#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *next_page;
const wchar_t *previous_page;
int count;
int i;
int count_i;
int id;
const wchar_t *url;
const wchar_t *name;
const wchar_t *email;
const wchar_t *created_at;
const wchar_t *updated_at;
const wchar_t *time_zone;
const wchar_t *phone;
const wchar_t *shared_phone_number;
const wchar_t *photo;
int locale_id;
const wchar_t *locale;
int organization_id;
const wchar_t *role;
BOOL verified;
const wchar_t *external_id;
const wchar_t *alias;
BOOL active;
BOOL shared;
BOOL shared_agent;
const wchar_t *last_login_at;
const wchar_t *two_factor_auth_enabled;
const wchar_t *signature;
const wchar_t *details;
const wchar_t *notes;
const wchar_t *role_type;
const wchar_t *custom_role_id;
BOOL moderator;
const wchar_t *ticket_restriction;
BOOL only_private_comments;
BOOL restricted_agent;
BOOL suspended;
BOOL chat_only;
int default_group_id;
const wchar_t *photoUrl;
int photoId;
const wchar_t *photoFile_name;
const wchar_t *photoContent_url;
const wchar_t *photoMapped_content_url;
const wchar_t *photoContent_type;
int photoSize;
int photoWidth;
int photoHeight;
BOOL photoInline;
int j;
int count_j;
const wchar_t *strVal;
const wchar_t *file_name;
const wchar_t *content_url;
const wchar_t *mapped_content_url;
const wchar_t *content_type;
int size;
int width;
int height;
BOOL inline;
rest = CkRestW_Create();
// URL: https://subdomain.zendesk.com/api/v2/users.json
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"subdomain.zendesk.com",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
CkRestW_SetAuthBasic(rest,L"zendesk_email/token",L"zendesk_api_token");
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/api/v2/users.json",sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
next_page = CkJsonObjectW_stringOf(jsonResponse,L"next_page");
previous_page = CkJsonObjectW_stringOf(jsonResponse,L"previous_page");
count = CkJsonObjectW_IntOf(jsonResponse,L"count");
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"users");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
id = CkJsonObjectW_IntOf(jsonResponse,L"users[i].id");
url = CkJsonObjectW_stringOf(jsonResponse,L"users[i].url");
name = CkJsonObjectW_stringOf(jsonResponse,L"users[i].name");
email = CkJsonObjectW_stringOf(jsonResponse,L"users[i].email");
created_at = CkJsonObjectW_stringOf(jsonResponse,L"users[i].created_at");
updated_at = CkJsonObjectW_stringOf(jsonResponse,L"users[i].updated_at");
time_zone = CkJsonObjectW_stringOf(jsonResponse,L"users[i].time_zone");
phone = CkJsonObjectW_stringOf(jsonResponse,L"users[i].phone");
shared_phone_number = CkJsonObjectW_stringOf(jsonResponse,L"users[i].shared_phone_number");
photo = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo");
locale_id = CkJsonObjectW_IntOf(jsonResponse,L"users[i].locale_id");
locale = CkJsonObjectW_stringOf(jsonResponse,L"users[i].locale");
organization_id = CkJsonObjectW_IntOf(jsonResponse,L"users[i].organization_id");
role = CkJsonObjectW_stringOf(jsonResponse,L"users[i].role");
verified = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].verified");
external_id = CkJsonObjectW_stringOf(jsonResponse,L"users[i].external_id");
alias = CkJsonObjectW_stringOf(jsonResponse,L"users[i].alias");
active = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].active");
shared = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].shared");
shared_agent = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].shared_agent");
last_login_at = CkJsonObjectW_stringOf(jsonResponse,L"users[i].last_login_at");
two_factor_auth_enabled = CkJsonObjectW_stringOf(jsonResponse,L"users[i].two_factor_auth_enabled");
signature = CkJsonObjectW_stringOf(jsonResponse,L"users[i].signature");
details = CkJsonObjectW_stringOf(jsonResponse,L"users[i].details");
notes = CkJsonObjectW_stringOf(jsonResponse,L"users[i].notes");
role_type = CkJsonObjectW_stringOf(jsonResponse,L"users[i].role_type");
custom_role_id = CkJsonObjectW_stringOf(jsonResponse,L"users[i].custom_role_id");
moderator = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].moderator");
ticket_restriction = CkJsonObjectW_stringOf(jsonResponse,L"users[i].ticket_restriction");
only_private_comments = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].only_private_comments");
restricted_agent = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].restricted_agent");
suspended = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].suspended");
chat_only = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].chat_only");
default_group_id = CkJsonObjectW_IntOf(jsonResponse,L"users[i].default_group_id");
photoUrl = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.url");
photoId = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.id");
photoFile_name = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.file_name");
photoContent_url = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.content_url");
photoMapped_content_url = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.mapped_content_url");
photoContent_type = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.content_type");
photoSize = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.size");
photoWidth = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.width");
photoHeight = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.height");
photoInline = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].photo.inline");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"users[i].tags");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
strVal = CkJsonObjectW_stringOf(jsonResponse,L"users[i].tags[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"users[i].photo.thumbnails");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
url = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.thumbnails[j].url");
id = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.thumbnails[j].id");
file_name = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.thumbnails[j].file_name");
content_url = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.thumbnails[j].content_url");
mapped_content_url = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.thumbnails[j].mapped_content_url");
content_type = CkJsonObjectW_stringOf(jsonResponse,L"users[i].photo.thumbnails[j].content_type");
size = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.thumbnails[j].size");
width = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.thumbnails[j].width");
height = CkJsonObjectW_IntOf(jsonResponse,L"users[i].photo.thumbnails[j].height");
inline = CkJsonObjectW_BoolOf(jsonResponse,L"users[i].photo.thumbnails[j].inline");
j = j + 1;
}
i = i + 1;
}
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"users": [
{
"id": 361801727573,
"url": "https://chilkat.zendesk.com/api/v2/users/361801727573.json",
"name": "Matt Fausey",
"email": "admin@chilkatsoft.com",
"created_at": "2018-04-14T19:01:56Z",
"updated_at": "2018-04-14T23:09:24Z",
"time_zone": "Bogota",
"phone": null,
"shared_phone_number": null,
"photo": null,
"locale_id": 1,
"locale": "en-US",
"organization_id": 360015071793,
"role": "admin",
"verified": true,
"external_id": null,
"tags": [
],
"alias": null,
"active": true,
"shared": false,
"shared_agent": false,
"last_login_at": "2018-04-14T23:09:24Z",
"two_factor_auth_enabled": null,
"signature": null,
"details": null,
"notes": null,
"role_type": null,
"custom_role_id": null,
"moderator": true,
"ticket_restriction": null,
"only_private_comments": false,
"restricted_agent": false,
"suspended": false,
"chat_only": false,
"default_group_id": 360000681553,
"user_fields": {}
},
{
"id": 361809055094,
"url": "https://chilkat.zendesk.com/api/v2/users/361809055094.json",
"name": "Sample customer",
"email": "customer@example.com",
"created_at": "2018-04-14T19:01:56Z",
"updated_at": "2018-04-14T19:01:57Z",
"time_zone": "Bogota",
"phone": null,
"shared_phone_number": null,
"photo": {
"url": "https://chilkat.zendesk.com/api/v2/attachments/360103279093.json",
"id": 360103279093,
"file_name": "profile_image_361809055094_2287229.jpg",
"content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229.jpg",
"mapped_content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229.jpg",
"content_type": "image/jpeg",
"size": 2587,
"width": 40,
"height": 40,
"inline": false,
"thumbnails": [
{
"url": "https://chilkat.zendesk.com/api/v2/attachments/360103279113.json",
"id": 360103279113,
"file_name": "profile_image_361809055094_2287229_thumb.jpg",
"content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229_thumb.jpg",
"mapped_content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229_thumb.jpg",
"content_type": "image/jpeg",
"size": 1980,
"width": 32,
"height": 32,
"inline": false
}
]
},
"locale_id": 1,
"locale": "en-US",
"organization_id": null,
"role": "end-user",
"verified": false,
"external_id": null,
"tags": [
],
"alias": null,
"active": true,
"shared": false,
"shared_agent": false,
"last_login_at": null,
"two_factor_auth_enabled": false,
"signature": null,
"details": null,
"notes": null,
"role_type": null,
"custom_role_id": null,
"moderator": false,
"ticket_restriction": "requested",
"only_private_comments": false,
"restricted_agent": true,
"suspended": false,
"chat_only": false,
"default_group_id": null,
"user_fields": {}
},
{
"id": 361810194934,
"url": "https://chilkat.zendesk.com/api/v2/users/361810194934.json",
"name": "matt",
"email": "matt@chilkat.io",
"created_at": "2018-04-14T20:58:33Z",
"updated_at": "2018-04-14T20:59:40Z",
"time_zone": "Central Time (US & Canada)",
"phone": null,
"shared_phone_number": null,
"photo": null,
"locale_id": 1,
"locale": "en-US",
"organization_id": 360015071793,
"role": "end-user",
"verified": false,
"external_id": null,
"tags": [
"lizard",
"gecko"
],
"alias": "",
"active": true,
"shared": false,
"shared_agent": false,
"last_login_at": null,
"two_factor_auth_enabled": false,
"signature": null,
"details": "",
"notes": "Likes coffee",
"role_type": null,
"custom_role_id": null,
"moderator": false,
"ticket_restriction": "requested",
"only_private_comments": false,
"restricted_agent": true,
"suspended": false,
"chat_only": false,
"default_group_id": null,
"user_fields": {}
},
{
"id": 361811376954,
"url": "https://chilkat.zendesk.com/api/v2/users/361811376954.json",
"name": "Roger Wilco",
"email": "roger@chilkat.io",
"created_at": "2018-04-14T23:09:24Z",
"updated_at": "2018-04-14T23:09:24Z",
"time_zone": "Bogota",
"phone": null,
"shared_phone_number": null,
"photo": null,
"locale_id": 1,
"locale": "en-US",
"organization_id": null,
"role": "end-user",
"verified": false,
"external_id": null,
"tags": [
],
"alias": null,
"active": true,
"shared": false,
"shared_agent": false,
"last_login_at": null,
"two_factor_auth_enabled": false,
"signature": null,
"details": null,
"notes": null,
"role_type": null,
"custom_role_id": null,
"moderator": false,
"ticket_restriction": "requested",
"only_private_comments": false,
"restricted_agent": true,
"suspended": false,
"chat_only": false,
"default_group_id": null,
"user_fields": {}
}
],
"next_page": null,
"previous_page": null,
"count": 4
}