Swift3 / Support API / Recover Multiple Suspended Tickets
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/suspended_tickets/recover_many?ids=<string>")
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)
// {
// "tickets": [
// {
// "attachments": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>",
// "thumbnails": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// }
// ]
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>",
// "thumbnails": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// }
// ]
// }
// ],
// "author": {
// "email": "<string>",
// "id": "<integer>",
// "name": "<string>"
// },
// "brand_id": "<integer>",
// "cause": "<string>",
// "cause_id": "<integer>",
// "content": "<string>",
// "created_at": "<dateTime>",
// "id": "<integer>",
// "message_id": "<string>",
// "recipient": "<string>",
// "subject": "<string>",
// "ticket_id": "<integer>",
// "updated_at": "<dateTime>",
// "url": "<string>",
// "via": {
// "channel": "<string>",
// "source": {
// "from": {
// "address": "<string>",
// "id": "<integer>",
// "name": "<string>",
// "title": "<string>"
// },
// "rel": "<string>",
// "to": {
// "address": "<string>",
// "name": "<string>"
// },
// "dolore58f": -60495356.51097781
// }
// }
// },
// {
// "attachments": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>",
// "thumbnails": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// }
// ]
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>",
// "thumbnails": [
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// },
// {
// "content_type": "<string>",
// "content_url": "<string>",
// "deleted": "<boolean>",
// "file_name": "<string>",
// "height": "<string>",
// "id": "<integer>",
// "inline": "<boolean>",
// "malware_access_override": "<boolean>",
// "malware_scan_result": "<string>",
// "mapped_content_url": "<string>",
// "size": "<integer>",
// "url": "<string>",
// "width": "<string>"
// }
// ]
// }
// ],
// "author": {
// "email": "<string>",
// "id": "<integer>",
// "name": "<string>"
// },
// "brand_id": "<integer>",
// "cause": "<string>",
// "cause_id": "<integer>",
// "content": "<string>",
// "created_at": "<dateTime>",
// "id": "<integer>",
// "message_id": "<string>",
// "recipient": "<string>",
// "subject": "<string>",
// "ticket_id": "<integer>",
// "updated_at": "<dateTime>",
// "url": "<string>",
// "via": {
// "channel": "<string>",
// "source": {
// "from": {
// "address": "<string>",
// "id": "<integer>",
// "name": "<string>",
// "title": "<string>"
// },
// "rel": "<string>",
// "to": {
// "address": "<string>",
// "name": "<string>"
// }
// }
// }
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var v_Email: String?
var Id: String?
var Name: String?
var brand_id: String?
var cause: String?
var cause_id: String?
var content: String?
var created_at: String?
var id: String?
var message_id: String?
var recipient: String?
var subject: String?
var ticket_id: String?
var updated_at: String?
var url: String?
var Channel: String?
var Address: String?
var FromId: String?
var FromName: String?
var Title: String?
var Rel: String?
var ToAddress: String?
var ToName: String?
var Dolore58f: String?
var j: Int
var count_j: Int
var content_type: String?
var content_url: String?
var deleted: String?
var file_name: String?
var height: String?
var inline: String?
var malware_access_override: String?
var malware_scan_result: String?
var mapped_content_url: String?
var size: String?
var width: String?
var k: Int
var count_k: Int
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "tickets").intValue
while i < count_i {
jResp.i = i
v_Email = jResp.string(of: "tickets[i].author.email")
Id = jResp.string(of: "tickets[i].author.id")
Name = jResp.string(of: "tickets[i].author.name")
brand_id = jResp.string(of: "tickets[i].brand_id")
cause = jResp.string(of: "tickets[i].cause")
cause_id = jResp.string(of: "tickets[i].cause_id")
content = jResp.string(of: "tickets[i].content")
created_at = jResp.string(of: "tickets[i].created_at")
id = jResp.string(of: "tickets[i].id")
message_id = jResp.string(of: "tickets[i].message_id")
recipient = jResp.string(of: "tickets[i].recipient")
subject = jResp.string(of: "tickets[i].subject")
ticket_id = jResp.string(of: "tickets[i].ticket_id")
updated_at = jResp.string(of: "tickets[i].updated_at")
url = jResp.string(of: "tickets[i].url")
Channel = jResp.string(of: "tickets[i].via.channel")
Address = jResp.string(of: "tickets[i].via.source.from.address")
FromId = jResp.string(of: "tickets[i].via.source.from.id")
FromName = jResp.string(of: "tickets[i].via.source.from.name")
Title = jResp.string(of: "tickets[i].via.source.from.title")
Rel = jResp.string(of: "tickets[i].via.source.rel")
ToAddress = jResp.string(of: "tickets[i].via.source.to.address")
ToName = jResp.string(of: "tickets[i].via.source.to.name")
Dolore58f = jResp.string(of: "tickets[i].via.source.dolore58f")
j = 0
count_j = jResp.size(ofArray: "tickets[i].attachments").intValue
while j < count_j {
jResp.j = j
content_type = jResp.string(of: "tickets[i].attachments[j].content_type")
content_url = jResp.string(of: "tickets[i].attachments[j].content_url")
deleted = jResp.string(of: "tickets[i].attachments[j].deleted")
file_name = jResp.string(of: "tickets[i].attachments[j].file_name")
height = jResp.string(of: "tickets[i].attachments[j].height")
id = jResp.string(of: "tickets[i].attachments[j].id")
inline = jResp.string(of: "tickets[i].attachments[j].inline")
malware_access_override = jResp.string(of: "tickets[i].attachments[j].malware_access_override")
malware_scan_result = jResp.string(of: "tickets[i].attachments[j].malware_scan_result")
mapped_content_url = jResp.string(of: "tickets[i].attachments[j].mapped_content_url")
size = jResp.string(of: "tickets[i].attachments[j].size")
url = jResp.string(of: "tickets[i].attachments[j].url")
width = jResp.string(of: "tickets[i].attachments[j].width")
k = 0
count_k = jResp.size(ofArray: "tickets[i].attachments[j].thumbnails").intValue
while k < count_k {
jResp.k = k
content_type = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].content_type")
content_url = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].content_url")
deleted = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].deleted")
file_name = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].file_name")
height = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].height")
id = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].id")
inline = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].inline")
malware_access_override = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].malware_access_override")
malware_scan_result = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].malware_scan_result")
mapped_content_url = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].mapped_content_url")
size = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].size")
url = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].url")
width = jResp.string(of: "tickets[i].attachments[j].thumbnails[k].width")
k = k + 1
}
j = j + 1
}
i = i + 1
}
}
Curl Command
curl -u login:password -X PUT
-H "Accept: application/json"
https://example.zendesk.com/api/v2/suspended_tickets/recover_many?ids=<string>
Postman Collection Item JSON
{
"name": "Recover Multiple Suspended Tickets",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/suspended_tickets/recover_many?ids=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"suspended_tickets",
"recover_many"
],
"query": [
{
"key": "ids",
"value": "<string>",
"description": "(Required) A comma separated list of ids of suspended tickets to recover."
}
]
},
"description": "Accepts up to 100 ids (the auto-generated id, not the ticket id.) Note that suspended tickets that fail to be recovered are still included in the response.\n\n#### Allowed For\n\n* Unrestricted agents\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/suspended_tickets/recover_many?ids=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"suspended_tickets",
"recover_many"
],
"query": [
{
"key": "ids",
"value": "<string>",
"description": "(Required) A comma separated list of ids of suspended tickets to recover."
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"tickets\": [\n {\n \"attachments\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\",\n \"thumbnails\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n }\n ]\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\",\n \"thumbnails\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n }\n ]\n }\n ],\n \"author\": {\n \"email\": \"<string>\",\n \"id\": \"<integer>\",\n \"name\": \"<string>\"\n },\n \"brand_id\": \"<integer>\",\n \"cause\": \"<string>\",\n \"cause_id\": \"<integer>\",\n \"content\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"id\": \"<integer>\",\n \"message_id\": \"<string>\",\n \"recipient\": \"<string>\",\n \"subject\": \"<string>\",\n \"ticket_id\": \"<integer>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\",\n \"via\": {\n \"channel\": \"<string>\",\n \"source\": {\n \"from\": {\n \"address\": \"<string>\",\n \"id\": \"<integer>\",\n \"name\": \"<string>\",\n \"title\": \"<string>\"\n },\n \"rel\": \"<string>\",\n \"to\": {\n \"address\": \"<string>\",\n \"name\": \"<string>\"\n },\n \"dolore58f\": -60495356.51097781\n }\n }\n },\n {\n \"attachments\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\",\n \"thumbnails\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n }\n ]\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\",\n \"thumbnails\": [\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n },\n {\n \"content_type\": \"<string>\",\n \"content_url\": \"<string>\",\n \"deleted\": \"<boolean>\",\n \"file_name\": \"<string>\",\n \"height\": \"<string>\",\n \"id\": \"<integer>\",\n \"inline\": \"<boolean>\",\n \"malware_access_override\": \"<boolean>\",\n \"malware_scan_result\": \"<string>\",\n \"mapped_content_url\": \"<string>\",\n \"size\": \"<integer>\",\n \"url\": \"<string>\",\n \"width\": \"<string>\"\n }\n ]\n }\n ],\n \"author\": {\n \"email\": \"<string>\",\n \"id\": \"<integer>\",\n \"name\": \"<string>\"\n },\n \"brand_id\": \"<integer>\",\n \"cause\": \"<string>\",\n \"cause_id\": \"<integer>\",\n \"content\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"id\": \"<integer>\",\n \"message_id\": \"<string>\",\n \"recipient\": \"<string>\",\n \"subject\": \"<string>\",\n \"ticket_id\": \"<integer>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\",\n \"via\": {\n \"channel\": \"<string>\",\n \"source\": {\n \"from\": {\n \"address\": \"<string>\",\n \"id\": \"<integer>\",\n \"name\": \"<string>\",\n \"title\": \"<string>\"\n },\n \"rel\": \"<string>\",\n \"to\": {\n \"address\": \"<string>\",\n \"name\": \"<string>\"\n }\n }\n }\n }\n ]\n}"
}
]
}