Objective-C / Support API / Recover Suspended Ticket
Back to Collection Items
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
http.BasicAuth = YES;
http.Login = @"login";
http.Password = @"password";
[http SetRequestHeader: @"Accept" value: @"application/json"];
CkoHttpResponse *resp = [http QuickRequest: @"PUT" url: @"https://example.zendesk.com/api/v2/suspended_tickets/:id/recover"];
if (http.LastMethodSuccess == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
[resp GetBodySb: sbResponseBody];
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);
int respStatusCode = [resp.StatusCode intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",resp.Header);
NSLog(@"%@",@"Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "ticket": [
// {
// "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>"
// }
// }
// }
// },
// {
// "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>"
// },
// "cupidatat__c": false,
// "officiad": -60680586
// }
// }
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
NSString *v_Email = 0;
NSString *Id = 0;
NSString *Name = 0;
NSString *brand_id = 0;
NSString *cause = 0;
NSString *cause_id = 0;
NSString *content = 0;
NSString *created_at = 0;
NSString *id = 0;
NSString *message_id = 0;
NSString *recipient = 0;
NSString *subject = 0;
NSString *ticket_id = 0;
NSString *updated_at = 0;
NSString *url = 0;
NSString *Channel = 0;
NSString *Address = 0;
NSString *FromId = 0;
NSString *FromName = 0;
NSString *Title = 0;
NSString *Rel = 0;
NSString *ToAddress = 0;
NSString *ToName = 0;
BOOL Cupidatat__c;
int Officiad;
int j;
int count_j;
NSString *content_type = 0;
NSString *content_url = 0;
NSString *deleted = 0;
NSString *file_name = 0;
NSString *height = 0;
NSString *inline = 0;
NSString *malware_access_override = 0;
NSString *malware_scan_result = 0;
NSString *mapped_content_url = 0;
NSString *size = 0;
NSString *width = 0;
int k;
int count_k;
int i = 0;
int count_i = [[jResp SizeOfArray: @"ticket"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
v_Email = [jResp StringOf: @"ticket[i].author.email"];
Id = [jResp StringOf: @"ticket[i].author.id"];
Name = [jResp StringOf: @"ticket[i].author.name"];
brand_id = [jResp StringOf: @"ticket[i].brand_id"];
cause = [jResp StringOf: @"ticket[i].cause"];
cause_id = [jResp StringOf: @"ticket[i].cause_id"];
content = [jResp StringOf: @"ticket[i].content"];
created_at = [jResp StringOf: @"ticket[i].created_at"];
id = [jResp StringOf: @"ticket[i].id"];
message_id = [jResp StringOf: @"ticket[i].message_id"];
recipient = [jResp StringOf: @"ticket[i].recipient"];
subject = [jResp StringOf: @"ticket[i].subject"];
ticket_id = [jResp StringOf: @"ticket[i].ticket_id"];
updated_at = [jResp StringOf: @"ticket[i].updated_at"];
url = [jResp StringOf: @"ticket[i].url"];
Channel = [jResp StringOf: @"ticket[i].via.channel"];
Address = [jResp StringOf: @"ticket[i].via.source.from.address"];
FromId = [jResp StringOf: @"ticket[i].via.source.from.id"];
FromName = [jResp StringOf: @"ticket[i].via.source.from.name"];
Title = [jResp StringOf: @"ticket[i].via.source.from.title"];
Rel = [jResp StringOf: @"ticket[i].via.source.rel"];
ToAddress = [jResp StringOf: @"ticket[i].via.source.to.address"];
ToName = [jResp StringOf: @"ticket[i].via.source.to.name"];
Cupidatat__c = [jResp BoolOf: @"ticket[i].via.source.cupidatat__c"];
Officiad = [[jResp IntOf: @"ticket[i].via.source.officiad"] intValue];
j = 0;
count_j = [[jResp SizeOfArray: @"ticket[i].attachments"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
content_type = [jResp StringOf: @"ticket[i].attachments[j].content_type"];
content_url = [jResp StringOf: @"ticket[i].attachments[j].content_url"];
deleted = [jResp StringOf: @"ticket[i].attachments[j].deleted"];
file_name = [jResp StringOf: @"ticket[i].attachments[j].file_name"];
height = [jResp StringOf: @"ticket[i].attachments[j].height"];
id = [jResp StringOf: @"ticket[i].attachments[j].id"];
inline = [jResp StringOf: @"ticket[i].attachments[j].inline"];
malware_access_override = [jResp StringOf: @"ticket[i].attachments[j].malware_access_override"];
malware_scan_result = [jResp StringOf: @"ticket[i].attachments[j].malware_scan_result"];
mapped_content_url = [jResp StringOf: @"ticket[i].attachments[j].mapped_content_url"];
size = [jResp StringOf: @"ticket[i].attachments[j].size"];
url = [jResp StringOf: @"ticket[i].attachments[j].url"];
width = [jResp StringOf: @"ticket[i].attachments[j].width"];
k = 0;
count_k = [[jResp SizeOfArray: @"ticket[i].attachments[j].thumbnails"] intValue];
while (k < count_k) {
jResp.K = [NSNumber numberWithInt: k];
content_type = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].content_type"];
content_url = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].content_url"];
deleted = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].deleted"];
file_name = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].file_name"];
height = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].height"];
id = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].id"];
inline = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].inline"];
malware_access_override = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].malware_access_override"];
malware_scan_result = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].malware_scan_result"];
mapped_content_url = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].mapped_content_url"];
size = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].size"];
url = [jResp StringOf: @"ticket[i].attachments[j].thumbnails[k].url"];
width = [jResp StringOf: @"ticket[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/:id/recover
Postman Collection Item JSON
{
"name": "Recover Suspended Ticket",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/suspended_tickets/:id/recover",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"suspended_tickets",
":id",
"recover"
],
"variable": [
{
"key": "id",
"value": "<number>"
}
]
},
"description": "**Note**: During recovery, the API sets the requester to the authenticated agent who called the API, not the original requester. This prevents the ticket from being re-suspended after recovery. To preserve the original requester, use the [Recover Multiple Suspended Tickets](#recover-multiple-suspended-tickets) endpoint with the single ticket.\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/:id/recover",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"suspended_tickets",
":id",
"recover"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"ticket\": [\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 \"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 \"cupidatat__c\": false,\n \"officiad\": -60680586\n }\n }\n }\n ]\n}"
}
]
}