DataFlex / Support API / List deleted tickets
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vQueryParams
Handle hoQueryParams
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sId
String sName
String sDeleted_at
String sId
String sPrevious_state
String sSubject
String sCount
String sNext_page
String sPrevious_page
Integer i
Integer iCount_i
String sTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComBasicAuth Of hoHttp To True
Set ComLogin Of hoHttp To "login"
Set ComPassword Of hoHttp To "password"
Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
If (Not(IsComObjectCreated(hoQueryParams))) Begin
Send CreateComObject of hoQueryParams
End
Get ComUpdateString Of hoQueryParams "sort_by" "id" To iSuccess
Get ComUpdateString Of hoQueryParams "sort_order" "asc" To iSuccess
Send ComSetRequestHeader To hoHttp "Accept" "application/json"
Get pvComObject of hoQueryParams to vQueryParams
Get ComQuickRequestParams Of hoHttp "GET" "https://example.zendesk.com/api/v2/deleted_tickets" vQueryParams To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Send Destroy of hoResp
Procedure_Return
End
Send Destroy of hoResp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "deleted_tickets": [
// {
// "actor": {
// "id": "<integer>",
// "name": "<string>"
// },
// "deleted_at": "<string>",
// "id": "<integer>",
// "previous_state": "<string>",
// "subject": "<string>"
// },
// {
// "actor": {
// "id": "<integer>",
// "name": "<string>"
// },
// "deleted_at": "<string>",
// "id": "<integer>",
// "previous_state": "<string>",
// "subject": "<string>"
// }
// ],
// "count": "<integer>",
// "next_page": "<string>",
// "previous_page": "<string>"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Get ComStringOf Of hoJResp "count" To sCount
Get ComStringOf Of hoJResp "next_page" To sNext_page
Get ComStringOf Of hoJResp "previous_page" To sPrevious_page
Move 0 To i
Get ComSizeOfArray Of hoJResp "deleted_tickets" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "deleted_tickets[i].actor.id" To sId
Get ComStringOf Of hoJResp "deleted_tickets[i].actor.name" To sName
Get ComStringOf Of hoJResp "deleted_tickets[i].deleted_at" To sDeleted_at
Get ComStringOf Of hoJResp "deleted_tickets[i].id" To sId
Get ComStringOf Of hoJResp "deleted_tickets[i].previous_state" To sPrevious_state
Get ComStringOf Of hoJResp "deleted_tickets[i].subject" To sSubject
Move (i + 1) To i
Loop
End_Procedure
Curl Command
curl -u login:password -G -d "sort_by=id"
-d "sort_order=asc"
-H "Accept: application/json"
https://example.zendesk.com/api/v2/deleted_tickets
Postman Collection Item JSON
{
"name": "List deleted tickets",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/deleted_tickets?sort_by=id&sort_order=asc",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"deleted_tickets"
],
"query": [
{
"key": "sort_by",
"value": "id",
"description": "Sort by"
},
{
"key": "sort_order",
"value": "asc",
"description": "Sort order. Defaults to \"asc\""
}
]
},
"description": "Returns a maximum of 100 deleted tickets per page. See [Pagination](/api-reference/introduction/pagination/).\n\nThe results includes all deleted (and not yet archived) tickets that\nhave not yet been [scrubbed](https://support.zendesk.com/hc/en-us/articles/4408845703194#topic_fv5_w51_sdb) in the past 30 days. Archived tickets are\nnot included in the results. See [About archived tickets](https://support.zendesk.com/hc/en-us/articles/203657756)\nin the Support Help Center.\n\nThe tickets are ordered chronologically by created date, from oldest to newest.\nThe first ticket listed may not be the oldest ticket in your\naccount due to [ticket archiving](https://support.zendesk.com/hc/en-us/articles/203657756).\n\n#### Pagination\n\n- Cursor pagination (recommended)\n- Offset pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\n\nReturns a maximum of 100 records per page.\n\n#### Allowed For\n\n* Agents\n\n#### Rate Limit\n\nYou can make 10 requests every 1 minute using this endpoint.\nWhen making requests beyond page 100, you can make 5 requests every 1 minute.\nThe rate limiting mechanism behaves as described in\n[Monitoring your request activity](/api-reference/ticketing/account-configuration/usage_limits/#monitoring-your-request-activity) in the API introduction."
},
"response": [
{
"name": "Successful response",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/deleted_tickets?sort_by=id&sort_order=asc",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"deleted_tickets"
],
"query": [
{
"key": "sort_by",
"value": "id",
"description": "Sort by"
},
{
"key": "sort_order",
"value": "asc",
"description": "Sort order. Defaults to \"asc\""
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"deleted_tickets\": [\n {\n \"actor\": {\n \"id\": \"<integer>\",\n \"name\": \"<string>\"\n },\n \"deleted_at\": \"<string>\",\n \"id\": \"<integer>\",\n \"previous_state\": \"<string>\",\n \"subject\": \"<string>\"\n },\n {\n \"actor\": {\n \"id\": \"<integer>\",\n \"name\": \"<string>\"\n },\n \"deleted_at\": \"<string>\",\n \"id\": \"<integer>\",\n \"previous_state\": \"<string>\",\n \"subject\": \"<string>\"\n }\n ],\n \"count\": \"<integer>\",\n \"next_page\": \"<string>\",\n \"previous_page\": \"<string>\"\n}"
}
]
}