PureBasic / Support API / Reorder Ticket Forms
Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
CkHttp::setCkBasicAuth(http, 1)
CkHttp::setCkLogin(http, "login")
CkHttp::setCkPassword(http, "password")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
resp.i = CkHttp::ckQuickRequest(http,"PUT","https://example.zendesk.com/api/v2/ticket_forms/reorder")
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
ProcedureReturn
EndIf
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpResponse::ckGetBodySb(resp,sbResponseBody)
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttpResponse::ckHeader(resp)
Debug "Failed."
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
CkHttpResponse::ckDispose(resp)
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "ticket_forms": [
; {
; "name": "<string>",
; "active": "<boolean>",
; "agent_conditions": [
; {
; "adipisicing_648": -24086995
; },
; {
; "veniamf": "cupida"
; }
; ],
; "created_at": "<dateTime>",
; "default": "<boolean>",
; "display_name": "<string>",
; "end_user_conditions": [
; {
; "in_6b8": "Ut id",
; "magna1": -6245214
; },
; {
; "pariatur1": 67097325,
; "consectetur3": false,
; "sed_6f0": true
; }
; ],
; "end_user_visible": "<boolean>",
; "id": "<integer>",
; "in_all_brands": "<boolean>",
; "position": "<integer>",
; "raw_display_name": "<string>",
; "raw_name": "<string>",
; "restricted_brand_ids": [
; "<integer>",
; "<integer>"
; ],
; "ticket_field_ids": [
; "<integer>",
; "<integer>"
; ],
; "updated_at": "<dateTime>",
; "url": "<string>"
; },
; {
; "name": "<string>",
; "active": "<boolean>",
; "agent_conditions": [
; {
; "id9": "laborum veniam",
; "ametb8": false
; },
; {
; "ut08f": -79491980.10398532,
; "non81": "Duis est fugiat officia consequat"
; }
; ],
; "created_at": "<dateTime>",
; "default": "<boolean>",
; "display_name": "<string>",
; "end_user_conditions": [
; {
; "sint1d2": "sint ex et"
; },
; {
; "cupidatat_667": true,
; "magna_d8": 64894285.255497575
; }
; ],
; "end_user_visible": "<boolean>",
; "id": "<integer>",
; "in_all_brands": "<boolean>",
; "position": "<integer>",
; "raw_display_name": "<string>",
; "raw_name": "<string>",
; "restricted_brand_ids": [
; "<integer>",
; "<integer>"
; ],
; "ticket_field_ids": [
; "<integer>",
; "<integer>"
; ],
; "updated_at": "<dateTime>",
; "url": "<string>"
; }
; ]
; }
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
name.s
active.s
created_at.s
default.s
display_name.s
end_user_visible.s
id.s
in_all_brands.s
position.s
raw_display_name.s
raw_name.s
updated_at.s
url.s
j.i
count_j.i
adipisicing_648.i
veniamf.s
id9.s
ametb8.i
ut08f.s
non81.s
in_6b8.s
magna1.i
pariatur1.i
consectetur3.i
sed_6f0.i
sint1d2.s
cupidatat_667.i
magna_d8.s
strVal.s
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(jResp,"ticket_forms")
While i < count_i
CkJsonObject::setCkI(jResp, i)
name = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].name")
active = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].active")
created_at = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].created_at")
default = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].default")
display_name = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].display_name")
end_user_visible = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].end_user_visible")
id = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].id")
in_all_brands = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].in_all_brands")
position = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].position")
raw_display_name = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].raw_display_name")
raw_name = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].raw_name")
updated_at = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].updated_at")
url = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].url")
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"ticket_forms[i].agent_conditions")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
adipisicing_648 = CkJsonObject::ckIntOf(jResp,"ticket_forms[i].agent_conditions[j].adipisicing_648")
veniamf = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].agent_conditions[j].veniamf")
id9 = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].agent_conditions[j].id9")
ametb8 = CkJsonObject::ckBoolOf(jResp,"ticket_forms[i].agent_conditions[j].ametb8")
ut08f = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].agent_conditions[j].ut08f")
non81 = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].agent_conditions[j].non81")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"ticket_forms[i].end_user_conditions")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
in_6b8 = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].end_user_conditions[j].in_6b8")
magna1 = CkJsonObject::ckIntOf(jResp,"ticket_forms[i].end_user_conditions[j].magna1")
pariatur1 = CkJsonObject::ckIntOf(jResp,"ticket_forms[i].end_user_conditions[j].pariatur1")
consectetur3 = CkJsonObject::ckBoolOf(jResp,"ticket_forms[i].end_user_conditions[j].consectetur3")
sed_6f0 = CkJsonObject::ckBoolOf(jResp,"ticket_forms[i].end_user_conditions[j].sed_6f0")
sint1d2 = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].end_user_conditions[j].sint1d2")
cupidatat_667 = CkJsonObject::ckBoolOf(jResp,"ticket_forms[i].end_user_conditions[j].cupidatat_667")
magna_d8 = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].end_user_conditions[j].magna_d8")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"ticket_forms[i].restricted_brand_ids")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
strVal = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].restricted_brand_ids[j]")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(jResp,"ticket_forms[i].ticket_field_ids")
While j < count_j
CkJsonObject::setCkJ(jResp, j)
strVal = CkJsonObject::ckStringOf(jResp,"ticket_forms[i].ticket_field_ids[j]")
j = j + 1
Wend
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
Curl Command
curl -u login:password -X PUT
-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_forms/reorder
Postman Collection Item JSON
{
"name": "Reorder Ticket Forms",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_forms/reorder",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
"reorder"
]
},
"description": "#### Allowed For\n* Admins\n\n#### Request Parameters\n\nYou can pass in the following parameter in the payload:\n\n| Name | Type | Comment\n| ------------------- | ------ | --------\n| ticket_form_ids | array | An array of ticket form ids. Example: \"[2, 23, 46, 50]\"\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "PUT",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_forms/reorder",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
"reorder"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"ticket_forms\": [\n {\n \"name\": \"<string>\",\n \"active\": \"<boolean>\",\n \"agent_conditions\": [\n {\n \"adipisicing_648\": -24086995\n },\n {\n \"veniamf\": \"cupida\"\n }\n ],\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"display_name\": \"<string>\",\n \"end_user_conditions\": [\n {\n \"in_6b8\": \"Ut id\",\n \"magna1\": -6245214\n },\n {\n \"pariatur1\": 67097325,\n \"consectetur3\": false,\n \"sed_6f0\": true\n }\n ],\n \"end_user_visible\": \"<boolean>\",\n \"id\": \"<integer>\",\n \"in_all_brands\": \"<boolean>\",\n \"position\": \"<integer>\",\n \"raw_display_name\": \"<string>\",\n \"raw_name\": \"<string>\",\n \"restricted_brand_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"ticket_field_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n },\n {\n \"name\": \"<string>\",\n \"active\": \"<boolean>\",\n \"agent_conditions\": [\n {\n \"id9\": \"laborum veniam\",\n \"ametb8\": false\n },\n {\n \"ut08f\": -79491980.10398532,\n \"non81\": \"Duis est fugiat officia consequat\"\n }\n ],\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"display_name\": \"<string>\",\n \"end_user_conditions\": [\n {\n \"sint1d2\": \"sint ex et\"\n },\n {\n \"cupidatat_667\": true,\n \"magna_d8\": 64894285.255497575\n }\n ],\n \"end_user_visible\": \"<boolean>\",\n \"id\": \"<integer>\",\n \"in_all_brands\": \"<boolean>\",\n \"position\": \"<integer>\",\n \"raw_display_name\": \"<string>\",\n \"raw_name\": \"<string>\",\n \"restricted_brand_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"ticket_field_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n ]\n}"
}
]
}