SQL Server / Support API / Show Custom Ticket Status
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/custom_statuses/:custom_status_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)
-- {
-- "custom_status": {
-- "status_category": "open",
-- "agent_label": "<string>",
-- "active": "<boolean>",
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "description": "<string>",
-- "end_user_description": "<string>",
-- "end_user_label": "<string>",
-- "id": "<integer>",
-- "raw_agent_label": "<string>",
-- "raw_description": "<string>",
-- "raw_end_user_description": "<string>",
-- "raw_end_user_label": "<string>",
-- "updated_at": "<dateTime>"
-- }
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @Status_category nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Status_category OUT, 'custom_status.status_category'
DECLARE @Agent_label nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Agent_label OUT, 'custom_status.agent_label'
DECLARE @Active nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Active OUT, 'custom_status.active'
DECLARE @Created_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Created_at OUT, 'custom_status.created_at'
DECLARE @Default nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Default OUT, 'custom_status.default'
DECLARE @Description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'custom_status.description'
DECLARE @End_user_description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @End_user_description OUT, 'custom_status.end_user_description'
DECLARE @End_user_label nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @End_user_label OUT, 'custom_status.end_user_label'
DECLARE @Id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'custom_status.id'
DECLARE @Raw_agent_label nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Raw_agent_label OUT, 'custom_status.raw_agent_label'
DECLARE @Raw_description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Raw_description OUT, 'custom_status.raw_description'
DECLARE @Raw_end_user_description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Raw_end_user_description OUT, 'custom_status.raw_end_user_description'
DECLARE @Raw_end_user_label nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Raw_end_user_label OUT, 'custom_status.raw_end_user_label'
DECLARE @Updated_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Updated_at OUT, 'custom_status.updated_at'
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/custom_statuses/:custom_status_id
Postman Collection Item JSON
{
"name": "Show Custom Ticket Status",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/custom_statuses/:custom_status_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"custom_statuses",
":custom_status_id"
],
"variable": [
{
"key": "custom_status_id",
"value": "<integer>"
}
]
},
"description": "Returns the custom ticket status object.\n\n#### Allowed For\n\n* End Users\n"
},
"response": [
{
"name": "Custom Status",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/custom_statuses/:custom_status_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"custom_statuses",
":custom_status_id"
],
"variable": [
{
"key": "custom_status_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"custom_status\": {\n \"status_category\": \"open\",\n \"agent_label\": \"<string>\",\n \"active\": \"<boolean>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"end_user_description\": \"<string>\",\n \"end_user_label\": \"<string>\",\n \"id\": \"<integer>\",\n \"raw_agent_label\": \"<string>\",\n \"raw_description\": \"<string>\",\n \"raw_end_user_description\": \"<string>\",\n \"raw_end_user_label\": \"<string>\",\n \"updated_at\": \"<dateTime>\"\n }\n}"
}
]
}