SQL Server / Support API / List Requests
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
EXEC sp_OASetProperty @http, 'BasicAuth', 1
EXEC sp_OASetProperty @http, 'Login', 'login'
EXEC sp_OASetProperty @http, 'Password', 'password'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://example.zendesk.com/api/v2/requests', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
-- 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
DECLARE @subject nvarchar(4000)
DECLARE @assignee_id nvarchar(4000)
DECLARE @can_be_solved_by_me nvarchar(4000)
DECLARE @created_at nvarchar(4000)
DECLARE @custom_status_id nvarchar(4000)
DECLARE @description nvarchar(4000)
DECLARE @due_at nvarchar(4000)
DECLARE @followup_source_id nvarchar(4000)
DECLARE @group_id nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @is_public nvarchar(4000)
DECLARE @organization_id nvarchar(4000)
DECLARE @priority nvarchar(4000)
DECLARE @recipient nvarchar(4000)
DECLARE @requester_id nvarchar(4000)
DECLARE @solved nvarchar(4000)
DECLARE @status nvarchar(4000)
DECLARE @ticket_form_id nvarchar(4000)
DECLARE @v_type nvarchar(4000)
DECLARE @updated_at nvarchar(4000)
DECLARE @url nvarchar(4000)
DECLARE @Channel nvarchar(4000)
DECLARE @Sitde nvarchar(4000)
DECLARE @Id80 int
DECLARE @Esse2a int
DECLARE @Irure_8 int
DECLARE @In77 nvarchar(4000)
DECLARE @Nisi_0 nvarchar(4000)
DECLARE @j int
DECLARE @count_j int
DECLARE @strVal nvarchar(4000)
DECLARE @value nvarchar(4000)
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'requests'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @subject OUT, 'requests[i].subject'
EXEC sp_OAMethod @jResp, 'StringOf', @assignee_id OUT, 'requests[i].assignee_id'
EXEC sp_OAMethod @jResp, 'StringOf', @can_be_solved_by_me OUT, 'requests[i].can_be_solved_by_me'
EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'requests[i].created_at'
EXEC sp_OAMethod @jResp, 'StringOf', @custom_status_id OUT, 'requests[i].custom_status_id'
EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'requests[i].description'
EXEC sp_OAMethod @jResp, 'StringOf', @due_at OUT, 'requests[i].due_at'
EXEC sp_OAMethod @jResp, 'StringOf', @followup_source_id OUT, 'requests[i].followup_source_id'
EXEC sp_OAMethod @jResp, 'StringOf', @group_id OUT, 'requests[i].group_id'
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'requests[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @is_public OUT, 'requests[i].is_public'
EXEC sp_OAMethod @jResp, 'StringOf', @organization_id OUT, 'requests[i].organization_id'
EXEC sp_OAMethod @jResp, 'StringOf', @priority OUT, 'requests[i].priority'
EXEC sp_OAMethod @jResp, 'StringOf', @recipient OUT, 'requests[i].recipient'
EXEC sp_OAMethod @jResp, 'StringOf', @requester_id OUT, 'requests[i].requester_id'
EXEC sp_OAMethod @jResp, 'StringOf', @solved OUT, 'requests[i].solved'
EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'requests[i].status'
EXEC sp_OAMethod @jResp, 'StringOf', @ticket_form_id OUT, 'requests[i].ticket_form_id'
EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'requests[i].type'
EXEC sp_OAMethod @jResp, 'StringOf', @updated_at OUT, 'requests[i].updated_at'
EXEC sp_OAMethod @jResp, 'StringOf', @url OUT, 'requests[i].url'
EXEC sp_OAMethod @jResp, 'StringOf', @Channel OUT, 'requests[i].via.channel'
EXEC sp_OAMethod @jResp, 'StringOf', @Sitde OUT, 'requests[i].via.source.sitde'
EXEC sp_OAMethod @jResp, 'BoolOf', @Id80 OUT, 'requests[i].via.source.id80'
EXEC sp_OAMethod @jResp, 'BoolOf', @Esse2a OUT, 'requests[i].via.source.esse2a'
EXEC sp_OAMethod @jResp, 'BoolOf', @Irure_8 OUT, 'requests[i].via.source.irure_8'
EXEC sp_OAMethod @jResp, 'StringOf', @In77 OUT, 'requests[i].via.source.in77'
EXEC sp_OAMethod @jResp, 'StringOf', @Nisi_0 OUT, 'requests[i].via.source.nisi_0'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'requests[i].collaborator_ids'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'requests[i].collaborator_ids[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'requests[i].custom_fields'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'requests[i].custom_fields[j].id'
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'requests[i].custom_fields[j].value'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'requests[i].email_cc_ids'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'requests[i].email_cc_ids[j]'
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
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}"
}
]
}