Chilkat Online Tools

Foxpro / Support API / Show Multiple Tickets

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loQueryParams
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcRequester_id
LOCAL lcAllow_attachments
LOCAL lcAllow_channelback
LOCAL lcAssignee_email
LOCAL lcAssignee_id
LOCAL lcAttribute_value_ids
LOCAL lcBrand_id
LOCAL lcCollaborator_ids
LOCAL lcCreated_at
LOCAL lcCustom_fields
LOCAL lcCustom_status_id
LOCAL lcDescription
LOCAL lcDue_at
LOCAL lcEmail_cc_ids
LOCAL lcExternal_id
LOCAL lcFollower_ids
LOCAL lcFollowup_ids
LOCAL lcForum_topic_id
LOCAL lcFrom_messaging_channel
LOCAL lcGroup_id
LOCAL lcHas_incidents
LOCAL lcId
LOCAL lcIs_public
LOCAL lcMacro_id
LOCAL lcMacro_ids
LOCAL lcOrganization_id
LOCAL lcPriority
LOCAL lcProblem_id
LOCAL lcRaw_subject
LOCAL lcRecipient
LOCAL lcSafe_update
LOCAL lcMagnaae
LOCAL lnNisi19
LOCAL lcSharing_agreement_ids
LOCAL lcStatus
LOCAL lcSubject
LOCAL lcSubmitter_id
LOCAL lcTags
LOCAL lcTicket_form_id
LOCAL lcV_type
LOCAL lcUpdated_at
LOCAL lcUpdated_stamp
LOCAL lcUrl
LOCAL lcChannel
LOCAL lcVeniam_79
LOCAL lcVia_followup_source_id
LOCAL lcVia_id
LOCAL lnEu_b
LOCAL lcId2
LOCAL lnEiusmod_13
LOCAL lcOccaecat1db
LOCAL j
LOCAL lnCount_j
LOCAL lcEmail
LOCAL lcName
LOCAL i
LOCAL lnCount_i

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loQueryParams = CreateObject('Chilkat.JsonObject')
loQueryParams.UpdateString("ids","<string>")

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

loResp = loHttp.QuickRequestParams("GET","https://example.zendesk.com/api/v2/tickets/show_many",loQueryParams)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loQueryParams
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    RELEASE loResp
    RELEASE loHttp
    RELEASE loQueryParams
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

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

* {
*   "tickets": [
*     {
*       "requester_id": "<integer>",
*       "allow_attachments": "<boolean>",
*       "allow_channelback": "<boolean>",
*       "assignee_email": "<string>",
*       "assignee_id": "<integer>",
*       "attribute_value_ids": "<array>",
*       "brand_id": "<integer>",
*       "collaborator_ids": "<array>",
*       "collaborators": [
*         {
*           "email": "<email>",
*           "name": "<string>"
*         },
*         {
*           "email": "<email>",
*           "name": "<string>"
*         }
*       ],
*       "comment": {},
*       "created_at": "<dateTime>",
*       "custom_fields": "<array>",
*       "custom_status_id": "<integer>",
*       "description": "<string>",
*       "due_at": "<dateTime>",
*       "email_cc_ids": "<array>",
*       "email_ccs": {},
*       "external_id": "<string>",
*       "follower_ids": "<array>",
*       "followers": {},
*       "followup_ids": "<array>",
*       "forum_topic_id": "<integer>",
*       "from_messaging_channel": "<boolean>",
*       "group_id": "<integer>",
*       "has_incidents": "<boolean>",
*       "id": "<integer>",
*       "is_public": "<boolean>",
*       "macro_id": "<integer>",
*       "macro_ids": "<array>",
*       "metadata": {},
*       "organization_id": "<integer>",
*       "priority": "normal",
*       "problem_id": "<integer>",
*       "raw_subject": "<string>",
*       "recipient": "<string>",
*       "requester": {},
*       "safe_update": "<boolean>",
*       "satisfaction_rating": {
*         "magnaae": 84328139.5577608,
*         "nisi19": true
*       },
*       "sharing_agreement_ids": "<array>",
*       "status": "new",
*       "subject": "<string>",
*       "submitter_id": "<integer>",
*       "tags": "<array>",
*       "ticket_form_id": "<integer>",
*       "type": "question",
*       "updated_at": "<dateTime>",
*       "updated_stamp": "<string>",
*       "url": "<string>",
*       "via": {
*         "channel": "<string>",
*         "source": {
*           "veniam_79": 90804961.49951228
*         }
*       },
*       "via_followup_source_id": "<integer>",
*       "via_id": "<integer>",
*       "voice_comment": {}
*     },
*     {
*       "requester_id": "<integer>",
*       "allow_attachments": "<boolean>",
*       "allow_channelback": "<boolean>",
*       "assignee_email": "<string>",
*       "assignee_id": "<integer>",
*       "attribute_value_ids": "<array>",
*       "brand_id": "<integer>",
*       "collaborator_ids": "<array>",
*       "collaborators": [
*         {
*           "email": "<email>",
*           "name": "<string>"
*         },
*         {
*           "email": "<email>",
*           "name": "<string>"
*         }
*       ],
*       "comment": {},
*       "created_at": "<dateTime>",
*       "custom_fields": "<array>",
*       "custom_status_id": "<integer>",
*       "description": "<string>",
*       "due_at": "<dateTime>",
*       "email_cc_ids": "<array>",
*       "email_ccs": {},
*       "external_id": "<string>",
*       "follower_ids": "<array>",
*       "followers": {},
*       "followup_ids": "<array>",
*       "forum_topic_id": "<integer>",
*       "from_messaging_channel": "<boolean>",
*       "group_id": "<integer>",
*       "has_incidents": "<boolean>",
*       "id": "<integer>",
*       "is_public": "<boolean>",
*       "macro_id": "<integer>",
*       "macro_ids": "<array>",
*       "metadata": {},
*       "organization_id": "<integer>",
*       "priority": "high",
*       "problem_id": "<integer>",
*       "raw_subject": "<string>",
*       "recipient": "<string>",
*       "requester": {},
*       "safe_update": "<boolean>",
*       "satisfaction_rating": {
*         "eu_b": 33777312
*       },
*       "sharing_agreement_ids": "<array>",
*       "status": "hold",
*       "subject": "<string>",
*       "submitter_id": "<integer>",
*       "tags": "<array>",
*       "ticket_form_id": "<integer>",
*       "type": "incident",
*       "updated_at": "<dateTime>",
*       "updated_stamp": "<string>",
*       "url": "<string>",
*       "via": {
*         "channel": "<string>",
*         "source": {
*           "id2": "cillum minim et",
*           "eiusmod_13": -64405368,
*           "occaecat1db": 1792444.0305951983
*         }
*       },
*       "via_followup_source_id": "<integer>",
*       "via_id": "<integer>",
*       "voice_comment": {}
*     }
*   ]
* }

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

i = 0
lnCount_i = loJResp.SizeOfArray("tickets")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcRequester_id = loJResp.StringOf("tickets[i].requester_id")
    lcAllow_attachments = loJResp.StringOf("tickets[i].allow_attachments")
    lcAllow_channelback = loJResp.StringOf("tickets[i].allow_channelback")
    lcAssignee_email = loJResp.StringOf("tickets[i].assignee_email")
    lcAssignee_id = loJResp.StringOf("tickets[i].assignee_id")
    lcAttribute_value_ids = loJResp.StringOf("tickets[i].attribute_value_ids")
    lcBrand_id = loJResp.StringOf("tickets[i].brand_id")
    lcCollaborator_ids = loJResp.StringOf("tickets[i].collaborator_ids")
    lcCreated_at = loJResp.StringOf("tickets[i].created_at")
    lcCustom_fields = loJResp.StringOf("tickets[i].custom_fields")
    lcCustom_status_id = loJResp.StringOf("tickets[i].custom_status_id")
    lcDescription = loJResp.StringOf("tickets[i].description")
    lcDue_at = loJResp.StringOf("tickets[i].due_at")
    lcEmail_cc_ids = loJResp.StringOf("tickets[i].email_cc_ids")
    lcExternal_id = loJResp.StringOf("tickets[i].external_id")
    lcFollower_ids = loJResp.StringOf("tickets[i].follower_ids")
    lcFollowup_ids = loJResp.StringOf("tickets[i].followup_ids")
    lcForum_topic_id = loJResp.StringOf("tickets[i].forum_topic_id")
    lcFrom_messaging_channel = loJResp.StringOf("tickets[i].from_messaging_channel")
    lcGroup_id = loJResp.StringOf("tickets[i].group_id")
    lcHas_incidents = loJResp.StringOf("tickets[i].has_incidents")
    lcId = loJResp.StringOf("tickets[i].id")
    lcIs_public = loJResp.StringOf("tickets[i].is_public")
    lcMacro_id = loJResp.StringOf("tickets[i].macro_id")
    lcMacro_ids = loJResp.StringOf("tickets[i].macro_ids")
    lcOrganization_id = loJResp.StringOf("tickets[i].organization_id")
    lcPriority = loJResp.StringOf("tickets[i].priority")
    lcProblem_id = loJResp.StringOf("tickets[i].problem_id")
    lcRaw_subject = loJResp.StringOf("tickets[i].raw_subject")
    lcRecipient = loJResp.StringOf("tickets[i].recipient")
    lcSafe_update = loJResp.StringOf("tickets[i].safe_update")
    lcMagnaae = loJResp.StringOf("tickets[i].satisfaction_rating.magnaae")
    lnNisi19 = loJResp.BoolOf("tickets[i].satisfaction_rating.nisi19")
    lcSharing_agreement_ids = loJResp.StringOf("tickets[i].sharing_agreement_ids")
    lcStatus = loJResp.StringOf("tickets[i].status")
    lcSubject = loJResp.StringOf("tickets[i].subject")
    lcSubmitter_id = loJResp.StringOf("tickets[i].submitter_id")
    lcTags = loJResp.StringOf("tickets[i].tags")
    lcTicket_form_id = loJResp.StringOf("tickets[i].ticket_form_id")
    lcV_type = loJResp.StringOf("tickets[i].type")
    lcUpdated_at = loJResp.StringOf("tickets[i].updated_at")
    lcUpdated_stamp = loJResp.StringOf("tickets[i].updated_stamp")
    lcUrl = loJResp.StringOf("tickets[i].url")
    lcChannel = loJResp.StringOf("tickets[i].via.channel")
    lcVeniam_79 = loJResp.StringOf("tickets[i].via.source.veniam_79")
    lcVia_followup_source_id = loJResp.StringOf("tickets[i].via_followup_source_id")
    lcVia_id = loJResp.StringOf("tickets[i].via_id")
    lnEu_b = loJResp.IntOf("tickets[i].satisfaction_rating.eu_b")
    lcId2 = loJResp.StringOf("tickets[i].via.source.id2")
    lnEiusmod_13 = loJResp.IntOf("tickets[i].via.source.eiusmod_13")
    lcOccaecat1db = loJResp.StringOf("tickets[i].via.source.occaecat1db")
    j = 0
    lnCount_j = loJResp.SizeOfArray("tickets[i].collaborators")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcEmail = loJResp.StringOf("tickets[i].collaborators[j].email")
        lcName = loJResp.StringOf("tickets[i].collaborators[j].name")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loQueryParams
RELEASE loSbResponseBody
RELEASE loJResp

Curl Command

curl  -u login:password -G -d "ids=%3Cstring%3E"
	-H "Accept: application/json"
https://example.zendesk.com/api/v2/tickets/show_many

Postman Collection Item JSON

{
  "name": "Show Multiple Tickets",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v2/tickets/show_many?ids=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v2",
        "tickets",
        "show_many"
      ],
      "query": [
        {
          "key": "ids",
          "value": "<string>",
          "description": "(Required) Comma-separated list of ticket ids"
        }
      ]
    },
    "description": "Accepts a comma-separated list of ticket ids to return.\n\nThis endpoint will return up to 100 tickets records.\n\n#### Allowed For\n* Agents"
  },
  "response": [
    {
      "name": "List tickets",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v2/tickets/show_many?ids=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v2",
            "tickets",
            "show_many"
          ],
          "query": [
            {
              "key": "ids",
              "value": "<string>",
              "description": "(Required) Comma-separated list of ticket ids"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"tickets\": [\n    {\n      \"requester_id\": \"<integer>\",\n      \"allow_attachments\": \"<boolean>\",\n      \"allow_channelback\": \"<boolean>\",\n      \"assignee_email\": \"<string>\",\n      \"assignee_id\": \"<integer>\",\n      \"attribute_value_ids\": \"<array>\",\n      \"brand_id\": \"<integer>\",\n      \"collaborator_ids\": \"<array>\",\n      \"collaborators\": [\n        {\n          \"email\": \"<email>\",\n          \"name\": \"<string>\"\n        },\n        {\n          \"email\": \"<email>\",\n          \"name\": \"<string>\"\n        }\n      ],\n      \"comment\": {},\n      \"created_at\": \"<dateTime>\",\n      \"custom_fields\": \"<array>\",\n      \"custom_status_id\": \"<integer>\",\n      \"description\": \"<string>\",\n      \"due_at\": \"<dateTime>\",\n      \"email_cc_ids\": \"<array>\",\n      \"email_ccs\": {},\n      \"external_id\": \"<string>\",\n      \"follower_ids\": \"<array>\",\n      \"followers\": {},\n      \"followup_ids\": \"<array>\",\n      \"forum_topic_id\": \"<integer>\",\n      \"from_messaging_channel\": \"<boolean>\",\n      \"group_id\": \"<integer>\",\n      \"has_incidents\": \"<boolean>\",\n      \"id\": \"<integer>\",\n      \"is_public\": \"<boolean>\",\n      \"macro_id\": \"<integer>\",\n      \"macro_ids\": \"<array>\",\n      \"metadata\": {},\n      \"organization_id\": \"<integer>\",\n      \"priority\": \"normal\",\n      \"problem_id\": \"<integer>\",\n      \"raw_subject\": \"<string>\",\n      \"recipient\": \"<string>\",\n      \"requester\": {},\n      \"safe_update\": \"<boolean>\",\n      \"satisfaction_rating\": {\n        \"magnaae\": 84328139.5577608,\n        \"nisi19\": true\n      },\n      \"sharing_agreement_ids\": \"<array>\",\n      \"status\": \"new\",\n      \"subject\": \"<string>\",\n      \"submitter_id\": \"<integer>\",\n      \"tags\": \"<array>\",\n      \"ticket_form_id\": \"<integer>\",\n      \"type\": \"question\",\n      \"updated_at\": \"<dateTime>\",\n      \"updated_stamp\": \"<string>\",\n      \"url\": \"<string>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"veniam_79\": 90804961.49951228\n        }\n      },\n      \"via_followup_source_id\": \"<integer>\",\n      \"via_id\": \"<integer>\",\n      \"voice_comment\": {}\n    },\n    {\n      \"requester_id\": \"<integer>\",\n      \"allow_attachments\": \"<boolean>\",\n      \"allow_channelback\": \"<boolean>\",\n      \"assignee_email\": \"<string>\",\n      \"assignee_id\": \"<integer>\",\n      \"attribute_value_ids\": \"<array>\",\n      \"brand_id\": \"<integer>\",\n      \"collaborator_ids\": \"<array>\",\n      \"collaborators\": [\n        {\n          \"email\": \"<email>\",\n          \"name\": \"<string>\"\n        },\n        {\n          \"email\": \"<email>\",\n          \"name\": \"<string>\"\n        }\n      ],\n      \"comment\": {},\n      \"created_at\": \"<dateTime>\",\n      \"custom_fields\": \"<array>\",\n      \"custom_status_id\": \"<integer>\",\n      \"description\": \"<string>\",\n      \"due_at\": \"<dateTime>\",\n      \"email_cc_ids\": \"<array>\",\n      \"email_ccs\": {},\n      \"external_id\": \"<string>\",\n      \"follower_ids\": \"<array>\",\n      \"followers\": {},\n      \"followup_ids\": \"<array>\",\n      \"forum_topic_id\": \"<integer>\",\n      \"from_messaging_channel\": \"<boolean>\",\n      \"group_id\": \"<integer>\",\n      \"has_incidents\": \"<boolean>\",\n      \"id\": \"<integer>\",\n      \"is_public\": \"<boolean>\",\n      \"macro_id\": \"<integer>\",\n      \"macro_ids\": \"<array>\",\n      \"metadata\": {},\n      \"organization_id\": \"<integer>\",\n      \"priority\": \"high\",\n      \"problem_id\": \"<integer>\",\n      \"raw_subject\": \"<string>\",\n      \"recipient\": \"<string>\",\n      \"requester\": {},\n      \"safe_update\": \"<boolean>\",\n      \"satisfaction_rating\": {\n        \"eu_b\": 33777312\n      },\n      \"sharing_agreement_ids\": \"<array>\",\n      \"status\": \"hold\",\n      \"subject\": \"<string>\",\n      \"submitter_id\": \"<integer>\",\n      \"tags\": \"<array>\",\n      \"ticket_form_id\": \"<integer>\",\n      \"type\": \"incident\",\n      \"updated_at\": \"<dateTime>\",\n      \"updated_stamp\": \"<string>\",\n      \"url\": \"<string>\",\n      \"via\": {\n        \"channel\": \"<string>\",\n        \"source\": {\n          \"id2\": \"cillum minim et\",\n          \"eiusmod_13\": -64405368,\n          \"occaecat1db\": 1792444.0305951983\n        }\n      },\n      \"via_followup_source_id\": \"<integer>\",\n      \"via_id\": \"<integer>\",\n      \"voice_comment\": {}\n    }\n  ]\n}"
    }
  ]
}