Search and return JSON for open tickets.
curl -X GET https://subdomain.zendesk.com/api/v2/search.json \
-H "Accept: application/json" \
--data-urlencode "query=type:ticket status:open" \
-u zendesk_email:zendesk_password
#include <C_CkRestW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
const wchar_t *strResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *facets;
const wchar_t *next_page;
const wchar_t *previous_page;
int count;
int i;
int count_i;
const wchar_t *url;
int id;
const wchar_t *external_id;
const wchar_t *viaChannel;
const wchar_t *viaSourceRel;
const wchar_t *created_at;
const wchar_t *updated_at;
const wchar_t *type;
const wchar_t *subject;
const wchar_t *raw_subject;
const wchar_t *description;
const wchar_t *priority;
const wchar_t *status;
const wchar_t *recipient;
int requester_id;
int submitter_id;
int assignee_id;
int organization_id;
int group_id;
const wchar_t *forum_topic_id;
const wchar_t *problem_id;
BOOL has_incidents;
BOOL is_public;
const wchar_t *due_at;
const wchar_t *satisfaction_rating;
int brand_id;
BOOL allow_channelback;
const wchar_t *result_type;
int j;
int count_j;
const wchar_t *strVal;
rest = CkRestW_Create();
// URL: https://subdomain.zendesk.com/api/v2/search.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",L"zendesk_password");
CkRestW_AddQueryParam(rest,L"query",L"type:ticket status:open");
CkRestW_AddHeader(rest,L"Accept",L"application/json");
strResponseBody = CkRestW_fullRequestFormUrlEncoded(rest,L"GET",L"/api/v2/search.json");
if (CkRestW_getLastMethodSuccess(rest) != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
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",strResponseBody);
CkRestW_Dispose(rest);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_Load(jsonResponse,strResponseBody);
facets = CkJsonObjectW_stringOf(jsonResponse,L"facets");
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"results");
while (i < count_i) {
CkJsonObjectW_putI(jsonResponse,i);
url = CkJsonObjectW_stringOf(jsonResponse,L"results[i].url");
id = CkJsonObjectW_IntOf(jsonResponse,L"results[i].id");
external_id = CkJsonObjectW_stringOf(jsonResponse,L"results[i].external_id");
viaChannel = CkJsonObjectW_stringOf(jsonResponse,L"results[i].via.channel");
viaSourceRel = CkJsonObjectW_stringOf(jsonResponse,L"results[i].via.source.rel");
created_at = CkJsonObjectW_stringOf(jsonResponse,L"results[i].created_at");
updated_at = CkJsonObjectW_stringOf(jsonResponse,L"results[i].updated_at");
type = CkJsonObjectW_stringOf(jsonResponse,L"results[i].type");
subject = CkJsonObjectW_stringOf(jsonResponse,L"results[i].subject");
raw_subject = CkJsonObjectW_stringOf(jsonResponse,L"results[i].raw_subject");
description = CkJsonObjectW_stringOf(jsonResponse,L"results[i].description");
priority = CkJsonObjectW_stringOf(jsonResponse,L"results[i].priority");
status = CkJsonObjectW_stringOf(jsonResponse,L"results[i].status");
recipient = CkJsonObjectW_stringOf(jsonResponse,L"results[i].recipient");
requester_id = CkJsonObjectW_IntOf(jsonResponse,L"results[i].requester_id");
submitter_id = CkJsonObjectW_IntOf(jsonResponse,L"results[i].submitter_id");
assignee_id = CkJsonObjectW_IntOf(jsonResponse,L"results[i].assignee_id");
organization_id = CkJsonObjectW_IntOf(jsonResponse,L"results[i].organization_id");
group_id = CkJsonObjectW_IntOf(jsonResponse,L"results[i].group_id");
forum_topic_id = CkJsonObjectW_stringOf(jsonResponse,L"results[i].forum_topic_id");
problem_id = CkJsonObjectW_stringOf(jsonResponse,L"results[i].problem_id");
has_incidents = CkJsonObjectW_BoolOf(jsonResponse,L"results[i].has_incidents");
is_public = CkJsonObjectW_BoolOf(jsonResponse,L"results[i].is_public");
due_at = CkJsonObjectW_stringOf(jsonResponse,L"results[i].due_at");
satisfaction_rating = CkJsonObjectW_stringOf(jsonResponse,L"results[i].satisfaction_rating");
brand_id = CkJsonObjectW_IntOf(jsonResponse,L"results[i].brand_id");
allow_channelback = CkJsonObjectW_BoolOf(jsonResponse,L"results[i].allow_channelback");
result_type = CkJsonObjectW_stringOf(jsonResponse,L"results[i].result_type");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].collaborator_ids");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].follower_ids");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].email_cc_ids");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].tags");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
strVal = CkJsonObjectW_stringOf(jsonResponse,L"results[i].tags[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].custom_fields");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].sharing_agreement_ids");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].fields");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jsonResponse,L"results[i].followup_ids");
while (j < count_j) {
CkJsonObjectW_putJ(jsonResponse,j);
j = j + 1;
}
i = i + 1;
}
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"results": [
{
"url": "https://chilkat.zendesk.com/api/v2/tickets/4.json",
"id": 4,
"external_id": null,
"via": {
"channel": "web",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2018-04-14T21:06:06Z",
"updated_at": "2018-04-14T21:06:06Z",
"type": "incident",
"subject": "Fix bug in software",
"raw_subject": "Fix bug in software",
"description": "Fix a bug in the software...",
"priority": "urgent",
"status": "open",
"recipient": null,
"requester_id": 361801727573,
"submitter_id": 361801727573,
"assignee_id": 361801727573,
"organization_id": 360015071793,
"group_id": 360000681553,
"collaborator_ids": [
],
"follower_ids": [
],
"email_cc_ids": [
],
"forum_topic_id": null,
"problem_id": null,
"has_incidents": false,
"is_public": true,
"due_at": null,
"tags": [
"bug"
],
"custom_fields": [
],
"satisfaction_rating": null,
"sharing_agreement_ids": [
],
"fields": [
],
"followup_ids": [
],
"brand_id": 360000471533,
"allow_channelback": false,
"result_type": "ticket"
},
{
"url": "https://chilkat.zendesk.com/api/v2/tickets/3.json",
"id": 3,
"external_id": null,
"via": {
"channel": "web",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2018-04-14T21:03:21Z",
"updated_at": "2018-04-14T21:03:21Z",
"type": "task",
"subject": "Add cool new feature.",
"raw_subject": "Add cool new feature.",
"description": "Add a cool new feature to the product.",
"priority": "high",
"status": "open",
"recipient": null,
"requester_id": 361801727573,
"submitter_id": 361801727573,
"assignee_id": 361801727573,
"organization_id": 360015071793,
"group_id": 360000681553,
"collaborator_ids": [
],
"follower_ids": [
],
"email_cc_ids": [
],
"forum_topic_id": null,
"problem_id": null,
"has_incidents": false,
"is_public": true,
"due_at": "2018-04-18T17:00:00Z",
"tags": [
"cool",
"feature"
],
"custom_fields": [
],
"satisfaction_rating": null,
"sharing_agreement_ids": [
],
"fields": [
],
"followup_ids": [
],
"brand_id": 360000471533,
"allow_channelback": false,
"result_type": "ticket"
},
{
"url": "https://chilkat.zendesk.com/api/v2/tickets/1.json",
"id": 1,
"external_id": null,
"via": {
"channel": "sample_ticket",
"source": {
"from": {},
"to": {},
"rel": null
}
},
"created_at": "2018-04-14T19:01:56Z",
"updated_at": "2018-04-14T19:01:57Z",
"type": "incident",
"subject": "Sample ticket: Meet the ticket",
"raw_subject": "Sample ticket: Meet the ticket",
"description": "Hi Matt,\n\nEmails, chats, voicemails, and tweets are captured in Zendesk Support as tickets. Start typing above to respond and click Submit to send. To test how an email becomes a ticket, send a message to support@chilkat.zendesk.com.\n\nCurious about what your customers will see when you reply? Check out this video:\nhttps://demos.zendesk.com/hc/en-us/articles/202341799\n",
"priority": "normal",
"status": "open",
"recipient": null,
"requester_id": 361809055094,
"submitter_id": 361801727573,
"assignee_id": 361801727573,
"organization_id": null,
"group_id": 360000681553,
"collaborator_ids": [
],
"follower_ids": [
],
"email_cc_ids": [
],
"forum_topic_id": null,
"problem_id": null,
"has_incidents": false,
"is_public": true,
"due_at": null,
"tags": [
"sample",
"support",
"zendesk"
],
"custom_fields": [
],
"satisfaction_rating": null,
"sharing_agreement_ids": [
],
"fields": [
],
"followup_ids": [
],
"brand_id": 360000471533,
"allow_channelback": false,
"result_type": "ticket"
}
],
"facets": null,
"next_page": null,
"previous_page": null,
"count": 3
}