Chilkat Online Tools

PowerBuilder / Support API / List Requests

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Subject
string ls_Assignee_id
string ls_Can_be_solved_by_me
string ls_Created_at
string ls_Custom_status_id
string ls_Description
string ls_Due_at
string ls_Followup_source_id
string ls_Group_id
string ls_Id
string ls_Is_public
string ls_Organization_id
string ls_Priority
string ls_Recipient
string ls_Requester_id
string ls_Solved
string ls_Status
string ls_Ticket_form_id
string ls_V_type
string ls_Updated_at
string ls_Url
string ls_Channel
string ls_Sitde
integer li_Id80
integer li_Esse2a
integer li_Irure_8
string ls_In77
string ls_Nisi_0
integer j
integer li_Count_j
string ls_StrVal
string ls_Value
integer i
integer li_Count_i

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.BasicAuth = 1
loo_Http.Login = "login"
loo_Http.Password = "password"

loo_Http.SetRequestHeader("Accept","application/json")

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://example.zendesk.com/api/v2/requests",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "requests": [
//     {
//       "subject": "<string>",
//       "assignee_id": "<integer>",
//       "can_be_solved_by_me": "<boolean>",
//       "collaborator_ids": [
//         "<integer>",
//         "<integer>"
//       ],
//       "created_at": "<dateTime>",
//       "custom_fields": [
//         {
//           "id": "<integer>",
//           "value": "<string>"
//         },
//         {
//           "id": "<integer>",
//           "value": "<string>"
//         }
//       ],
//       "custom_status_id": "<integer>",
//       "description": "<string>",
//       "due_at": "<dateTime>",
//       "email_cc_ids": [
//         "<integer>",
//         "<integer>"
//       ],
//       "followup_source_id": "<integer>",
//       "group_id": "<integer>",
//       "id": "<integer>",
//       "is_public": "<boolean>",
//       "organization_id": "<integer>",
//       "priority": "<string>",
//       "recipient": "<string>",
//       "requester_id": "<integer>",
//       "solved": "<boolean>",
//       "status": "<string>",
//       "ticket_form_id": "<integer>",
//       "type": "<string>",
//       "updated_at": "<dateTime>",
//       "url": "<string>",
//       "via": {
//         "channel": "<string>",
//         "source": {
//           "sitde": -5925380.425592765,
//           "id80": false
//         }
//       }
//     },
//     {
//       "subject": "<string>",
//       "assignee_id": "<integer>",
//       "can_be_solved_by_me": "<boolean>",
//       "collaborator_ids": [
//         "<integer>",
//         "<integer>"
//       ],
//       "created_at": "<dateTime>",
//       "custom_fields": [
//         {
//           "id": "<integer>",
//           "value": "<string>"
//         },
//         {
//           "id": "<integer>",
//           "value": "<string>"
//         }
//       ],
//       "custom_status_id": "<integer>",
//       "description": "<string>",
//       "due_at": "<dateTime>",
//       "email_cc_ids": [
//         "<integer>",
//         "<integer>"
//       ],
//       "followup_source_id": "<integer>",
//       "group_id": "<integer>",
//       "id": "<integer>",
//       "is_public": "<boolean>",
//       "organization_id": "<integer>",
//       "priority": "<string>",
//       "recipient": "<string>",
//       "requester_id": "<integer>",
//       "solved": "<boolean>",
//       "status": "<string>",
//       "ticket_form_id": "<integer>",
//       "type": "<string>",
//       "updated_at": "<dateTime>",
//       "url": "<string>",
//       "via": {
//         "channel": "<string>",
//         "source": {
//           "esse2a": false,
//           "irure_8": true,
//           "in77": 99886237.33060426,
//           "nisi_0": "occaecat velit voluptate consequat"
//         }
//       }
//     }
//   ]
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

i = 0
li_Count_i = loo_JResp.SizeOfArray("requests")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Subject = loo_JResp.StringOf("requests[i].subject")
    ls_Assignee_id = loo_JResp.StringOf("requests[i].assignee_id")
    ls_Can_be_solved_by_me = loo_JResp.StringOf("requests[i].can_be_solved_by_me")
    ls_Created_at = loo_JResp.StringOf("requests[i].created_at")
    ls_Custom_status_id = loo_JResp.StringOf("requests[i].custom_status_id")
    ls_Description = loo_JResp.StringOf("requests[i].description")
    ls_Due_at = loo_JResp.StringOf("requests[i].due_at")
    ls_Followup_source_id = loo_JResp.StringOf("requests[i].followup_source_id")
    ls_Group_id = loo_JResp.StringOf("requests[i].group_id")
    ls_Id = loo_JResp.StringOf("requests[i].id")
    ls_Is_public = loo_JResp.StringOf("requests[i].is_public")
    ls_Organization_id = loo_JResp.StringOf("requests[i].organization_id")
    ls_Priority = loo_JResp.StringOf("requests[i].priority")
    ls_Recipient = loo_JResp.StringOf("requests[i].recipient")
    ls_Requester_id = loo_JResp.StringOf("requests[i].requester_id")
    ls_Solved = loo_JResp.StringOf("requests[i].solved")
    ls_Status = loo_JResp.StringOf("requests[i].status")
    ls_Ticket_form_id = loo_JResp.StringOf("requests[i].ticket_form_id")
    ls_V_type = loo_JResp.StringOf("requests[i].type")
    ls_Updated_at = loo_JResp.StringOf("requests[i].updated_at")
    ls_Url = loo_JResp.StringOf("requests[i].url")
    ls_Channel = loo_JResp.StringOf("requests[i].via.channel")
    ls_Sitde = loo_JResp.StringOf("requests[i].via.source.sitde")
    li_Id80 = loo_JResp.BoolOf("requests[i].via.source.id80")
    li_Esse2a = loo_JResp.BoolOf("requests[i].via.source.esse2a")
    li_Irure_8 = loo_JResp.BoolOf("requests[i].via.source.irure_8")
    ls_In77 = loo_JResp.StringOf("requests[i].via.source.in77")
    ls_Nisi_0 = loo_JResp.StringOf("requests[i].via.source.nisi_0")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("requests[i].collaborator_ids")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("requests[i].collaborator_ids[j]")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("requests[i].custom_fields")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Id = loo_JResp.StringOf("requests[i].custom_fields[j].id")
        ls_Value = loo_JResp.StringOf("requests[i].custom_fields[j].value")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("requests[i].email_cc_ids")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("requests[i].email_cc_ids[j]")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl  -u login:password -X GET
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/requests

Postman Collection Item JSON

{
  "name": "List Requests",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/requests",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "requests"
      ],
      "variable": [
        {
          "key": "sort_by",
          "value": "<string>",
          "description": "Possible values are \"updated_at\", \"created_at\""
        },
        {
          "key": "sort_order",
          "value": "<string>",
          "description": "One of \"asc\", \"desc\". Defaults to \"asc\""
        }
      ]
    },
    "description": "#### Allowed for\n\n* End Users\n"
  },
  "response": [
    {
      "name": "Success response",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/requests",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "requests"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"requests\": [\n    {\n      \"subject\": \"<string>\",\n      \"assignee_id\": \"<integer>\",\n      \"can_be_solved_by_me\": \"<boolean>\",\n      \"collaborator_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"created_at\": \"<dateTime>\",\n      \"custom_fields\": [\n        {\n          \"id\": \"<integer>\",\n          \"value\": \"<string>\"\n        },\n        {\n          \"id\": \"<integer>\",\n          \"value\": \"<string>\"\n        }\n      ],\n      \"custom_status_id\": \"<integer>\",\n      \"description\": \"<string>\",\n      \"due_at\": \"<dateTime>\",\n      \"email_cc_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"followup_source_id\": \"<integer>\",\n      \"group_id\": \"<integer>\",\n      \"id\": \"<integer>\",\n      \"is_public\": \"<boolean>\",\n      \"organization_id\": \"<integer>\",\n      \"priority\": \"<string>\",\n      \"recipient\": \"<string>\",\n      \"requester_id\": \"<integer>\",\n      \"solved\": \"<boolean>\",\n      \"status\": \"<string>\",\n      \"ticket_form_id\": \"<integer>\",\n      \"type\": \"<string>\",\n      \"updated_at\": \"<dateTime>\",\n      \"url\": \"<string>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"sitde\": -5925380.425592765,\n          \"id80\": false\n        }\n      }\n    },\n    {\n      \"subject\": \"<string>\",\n      \"assignee_id\": \"<integer>\",\n      \"can_be_solved_by_me\": \"<boolean>\",\n      \"collaborator_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"created_at\": \"<dateTime>\",\n      \"custom_fields\": [\n        {\n          \"id\": \"<integer>\",\n          \"value\": \"<string>\"\n        },\n        {\n          \"id\": \"<integer>\",\n          \"value\": \"<string>\"\n        }\n      ],\n      \"custom_status_id\": \"<integer>\",\n      \"description\": \"<string>\",\n      \"due_at\": \"<dateTime>\",\n      \"email_cc_ids\": [\n        \"<integer>\",\n        \"<integer>\"\n      ],\n      \"followup_source_id\": \"<integer>\",\n      \"group_id\": \"<integer>\",\n      \"id\": \"<integer>\",\n      \"is_public\": \"<boolean>\",\n      \"organization_id\": \"<integer>\",\n      \"priority\": \"<string>\",\n      \"recipient\": \"<string>\",\n      \"requester_id\": \"<integer>\",\n      \"solved\": \"<boolean>\",\n      \"status\": \"<string>\",\n      \"ticket_form_id\": \"<integer>\",\n      \"type\": \"<string>\",\n      \"updated_at\": \"<dateTime>\",\n      \"url\": \"<string>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"esse2a\": false,\n          \"irure_8\": true,\n          \"in77\": 99886237.33060426,\n          \"nisi_0\": \"occaecat velit voluptate consequat\"\n        }\n      }\n    }\n  ]\n}"
    }
  ]
}