SQL Server / Support API / Show Request
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/:request_id', @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)
-- {
-- "request": {
-- "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": {
-- "est__": false
-- }
-- }
-- }
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @strVal nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @value nvarchar(4000)
DECLARE @Subject nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Subject OUT, 'request.subject'
DECLARE @Assignee_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Assignee_id OUT, 'request.assignee_id'
DECLARE @Can_be_solved_by_me nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Can_be_solved_by_me OUT, 'request.can_be_solved_by_me'
DECLARE @Created_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Created_at OUT, 'request.created_at'
DECLARE @Custom_status_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Custom_status_id OUT, 'request.custom_status_id'
DECLARE @Description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'request.description'
DECLARE @Due_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Due_at OUT, 'request.due_at'
DECLARE @Followup_source_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Followup_source_id OUT, 'request.followup_source_id'
DECLARE @Group_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Group_id OUT, 'request.group_id'
DECLARE @Id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'request.id'
DECLARE @Is_public nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Is_public OUT, 'request.is_public'
DECLARE @Organization_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Organization_id OUT, 'request.organization_id'
DECLARE @Priority nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Priority OUT, 'request.priority'
DECLARE @Recipient nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Recipient OUT, 'request.recipient'
DECLARE @Requester_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Requester_id OUT, 'request.requester_id'
DECLARE @Solved nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Solved OUT, 'request.solved'
DECLARE @Status nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'request.status'
DECLARE @Ticket_form_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_form_id OUT, 'request.ticket_form_id'
DECLARE @v_Type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'request.type'
DECLARE @Updated_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Updated_at OUT, 'request.updated_at'
DECLARE @v_Url nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Url OUT, 'request.url'
DECLARE @Channel nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Channel OUT, 'request.via.channel'
DECLARE @Est__ int
EXEC sp_OAMethod @jResp, 'BoolOf', @Est__ OUT, 'request.via.source.est__'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'request.collaborator_ids'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'request.collaborator_ids[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'request.custom_fields'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'request.custom_fields[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'request.custom_fields[i].value'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'request.email_cc_ids'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'request.email_cc_ids[i]'
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/:request_id
Postman Collection Item JSON
{
"name": "Show Request",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/requests/:request_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"requests",
":request_id"
],
"variable": [
{
"key": "request_id",
"value": "<integer>"
}
]
},
"description": "#### Sideloads\n\nThe following sideloads are supported:\n\n| Name | Will sideload\n| ---------------- | -------------\n| users | The email ccs for a request by side-loading users\n\n#### 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/:request_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"requests",
":request_id"
],
"variable": [
{
"key": "request_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"request\": {\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 \"est__\": false\n }\n }\n }\n}"
}
]
}