Swift3 / Support API / Update Ticket Form
Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
http.basicAuth = true
http.login = "login"
http.password = "password"
http.setRequestHeader("Accept", value: "application/json")
var resp: CkoHttpResponse? = http.quickRequest("PUT", url: "https://example.zendesk.com/api/v2/ticket_forms/:ticket_form_id")
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
let sbResponseBody = CkoStringBuilder()!
resp!.getBodySb(sbResponseBody)
let jResp = CkoJsonObject()!
jResp.loadSb(sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = resp!.statusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(resp!.header!)")
print("Failed.")
resp = nil
return
}
resp = nil
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "ticket_form": {
// "name": "<string>",
// "active": "<boolean>",
// "agent_conditions": [
// {
// "aliqua6": "proident deserunt",
// "Lorem_d": "cillum dolor Excepteur ut",
// "mollit_cf": -33059877,
// "ullamco_f7": "dolore occaeca"
// },
// {
// "consequate_": 29214347.18513973,
// "consectetur_00": 83697330,
// "laborum50": "cillum Ut"
// }
// ],
// "created_at": "<dateTime>",
// "default": "<boolean>",
// "display_name": "<string>",
// "end_user_conditions": [
// {
// "irure__c": false,
// "Excepteur_38": -15203265.607602075,
// "sunt_8": "culpa laboris Ut"
// },
// {
// "nulla_48": "quis esse",
// "ullamco_f6": -25516091.19614251
// }
// ],
// "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
var aliqua6: String?
var Lorem_d: String?
var mollit_cf: Int
var ullamco_f7: String?
var consequate_: String?
var consectetur_00: Int
var laborum50: String?
var irure__c: Bool
var Excepteur_38: String?
var sunt_8: String?
var nulla_48: String?
var ullamco_f6: String?
var strVal: String?
var Name: String? = jResp.string(of: "ticket_form.name")
var Active: String? = jResp.string(of: "ticket_form.active")
var Created_at: String? = jResp.string(of: "ticket_form.created_at")
var Default: String? = jResp.string(of: "ticket_form.default")
var Display_name: String? = jResp.string(of: "ticket_form.display_name")
var End_user_visible: String? = jResp.string(of: "ticket_form.end_user_visible")
var Id: String? = jResp.string(of: "ticket_form.id")
var In_all_brands: String? = jResp.string(of: "ticket_form.in_all_brands")
var Position: String? = jResp.string(of: "ticket_form.position")
var Raw_display_name: String? = jResp.string(of: "ticket_form.raw_display_name")
var Raw_name: String? = jResp.string(of: "ticket_form.raw_name")
var Updated_at: String? = jResp.string(of: "ticket_form.updated_at")
var v_Url: String? = jResp.string(of: "ticket_form.url")
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "ticket_form.agent_conditions").intValue
while i < count_i {
jResp.i = i
aliqua6 = jResp.string(of: "ticket_form.agent_conditions[i].aliqua6")
Lorem_d = jResp.string(of: "ticket_form.agent_conditions[i].Lorem_d")
mollit_cf = jResp.int(of: "ticket_form.agent_conditions[i].mollit_cf").intValue
ullamco_f7 = jResp.string(of: "ticket_form.agent_conditions[i].ullamco_f7")
consequate_ = jResp.string(of: "ticket_form.agent_conditions[i].consequate_")
consectetur_00 = jResp.int(of: "ticket_form.agent_conditions[i].consectetur_00").intValue
laborum50 = jResp.string(of: "ticket_form.agent_conditions[i].laborum50")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "ticket_form.end_user_conditions").intValue
while i < count_i {
jResp.i = i
irure__c = jResp.bool(of: "ticket_form.end_user_conditions[i].irure__c")
Excepteur_38 = jResp.string(of: "ticket_form.end_user_conditions[i].Excepteur_38")
sunt_8 = jResp.string(of: "ticket_form.end_user_conditions[i].sunt_8")
nulla_48 = jResp.string(of: "ticket_form.end_user_conditions[i].nulla_48")
ullamco_f6 = jResp.string(of: "ticket_form.end_user_conditions[i].ullamco_f6")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "ticket_form.restricted_brand_ids").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "ticket_form.restricted_brand_ids[i]")
i = i + 1
}
i = 0
count_i = jResp.size(ofArray: "ticket_form.ticket_field_ids").intValue
while i < count_i {
jResp.i = i
strVal = jResp.string(of: "ticket_form.ticket_field_ids[i]")
i = i + 1
}
}
Curl Command
curl -u login:password -X PUT
-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_forms/:ticket_form_id
Postman Collection Item JSON
{
"name": "Update Ticket Form",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_forms/:ticket_form_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
":ticket_form_id"
],
"variable": [
{
"key": "ticket_form_id",
"value": "<integer>"
}
]
},
"description": "#### Allowed For\n* Admins\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/:ticket_form_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
":ticket_form_id"
],
"variable": [
{
"key": "ticket_form_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"ticket_form\": {\n \"name\": \"<string>\",\n \"active\": \"<boolean>\",\n \"agent_conditions\": [\n {\n \"aliqua6\": \"proident deserunt\",\n \"Lorem_d\": \"cillum dolor Excepteur ut\",\n \"mollit_cf\": -33059877,\n \"ullamco_f7\": \"dolore occaeca\"\n },\n {\n \"consequate_\": 29214347.18513973,\n \"consectetur_00\": 83697330,\n \"laborum50\": \"cillum Ut\"\n }\n ],\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"display_name\": \"<string>\",\n \"end_user_conditions\": [\n {\n \"irure__c\": false,\n \"Excepteur_38\": -15203265.607602075,\n \"sunt_8\": \"culpa laboris Ut\"\n },\n {\n \"nulla_48\": \"quis esse\",\n \"ullamco_f6\": -25516091.19614251\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}"
}
]
}