SQL Server / Support API / Show Ticket Form
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/ticket_forms/:ticket_form_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)
-- {
-- "ticket_form": {
-- "name": "<string>",
-- "active": "<boolean>",
-- "agent_conditions": [
-- {
-- "aliqua6": "proident deserunt",
-- "Lorem_d": "cillum dolor Excepteur ut",
-- "mollit_cf": -33059877,
-- "ullamco_f7": "dolore occaeca"
-- },
-- {
-- "consequate_": 29214347.18513973,
-- "consectetur_00": 83697330,
-- "laborum50": "cillum Ut"
-- }
-- ],
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "display_name": "<string>",
-- "end_user_conditions": [
-- {
-- "irure__c": false,
-- "Excepteur_38": -15203265.607602075,
-- "sunt_8": "culpa laboris Ut"
-- },
-- {
-- "nulla_48": "quis esse",
-- "ullamco_f6": -25516091.19614251
-- }
-- ],
-- "end_user_visible": "<boolean>",
-- "id": "<integer>",
-- "in_all_brands": "<boolean>",
-- "position": "<integer>",
-- "raw_display_name": "<string>",
-- "raw_name": "<string>",
-- "restricted_brand_ids": [
-- "<integer>",
-- "<integer>"
-- ],
-- "ticket_field_ids": [
-- "<integer>",
-- "<integer>"
-- ],
-- "updated_at": "<dateTime>",
-- "url": "<string>"
-- }
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @aliqua6 nvarchar(4000)
DECLARE @Lorem_d nvarchar(4000)
DECLARE @mollit_cf int
DECLARE @ullamco_f7 nvarchar(4000)
DECLARE @consequate_ nvarchar(4000)
DECLARE @consectetur_00 int
DECLARE @laborum50 nvarchar(4000)
DECLARE @irure__c int
DECLARE @Excepteur_38 nvarchar(4000)
DECLARE @sunt_8 nvarchar(4000)
DECLARE @nulla_48 nvarchar(4000)
DECLARE @ullamco_f6 nvarchar(4000)
DECLARE @strVal nvarchar(4000)
DECLARE @Name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ticket_form.name'
DECLARE @Active nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Active OUT, 'ticket_form.active'
DECLARE @Created_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Created_at OUT, 'ticket_form.created_at'
DECLARE @Default nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Default OUT, 'ticket_form.default'
DECLARE @Display_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Display_name OUT, 'ticket_form.display_name'
DECLARE @End_user_visible nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @End_user_visible OUT, 'ticket_form.end_user_visible'
DECLARE @Id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'ticket_form.id'
DECLARE @In_all_brands nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @In_all_brands OUT, 'ticket_form.in_all_brands'
DECLARE @Position nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Position OUT, 'ticket_form.position'
DECLARE @Raw_display_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Raw_display_name OUT, 'ticket_form.raw_display_name'
DECLARE @Raw_name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Raw_name OUT, 'ticket_form.raw_name'
DECLARE @Updated_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Updated_at OUT, 'ticket_form.updated_at'
DECLARE @v_Url nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Url OUT, 'ticket_form.url'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'ticket_form.agent_conditions'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @aliqua6 OUT, 'ticket_form.agent_conditions[i].aliqua6'
EXEC sp_OAMethod @jResp, 'StringOf', @Lorem_d OUT, 'ticket_form.agent_conditions[i].Lorem_d'
EXEC sp_OAMethod @jResp, 'IntOf', @mollit_cf OUT, 'ticket_form.agent_conditions[i].mollit_cf'
EXEC sp_OAMethod @jResp, 'StringOf', @ullamco_f7 OUT, 'ticket_form.agent_conditions[i].ullamco_f7'
EXEC sp_OAMethod @jResp, 'StringOf', @consequate_ OUT, 'ticket_form.agent_conditions[i].consequate_'
EXEC sp_OAMethod @jResp, 'IntOf', @consectetur_00 OUT, 'ticket_form.agent_conditions[i].consectetur_00'
EXEC sp_OAMethod @jResp, 'StringOf', @laborum50 OUT, 'ticket_form.agent_conditions[i].laborum50'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'ticket_form.end_user_conditions'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'BoolOf', @irure__c OUT, 'ticket_form.end_user_conditions[i].irure__c'
EXEC sp_OAMethod @jResp, 'StringOf', @Excepteur_38 OUT, 'ticket_form.end_user_conditions[i].Excepteur_38'
EXEC sp_OAMethod @jResp, 'StringOf', @sunt_8 OUT, 'ticket_form.end_user_conditions[i].sunt_8'
EXEC sp_OAMethod @jResp, 'StringOf', @nulla_48 OUT, 'ticket_form.end_user_conditions[i].nulla_48'
EXEC sp_OAMethod @jResp, 'StringOf', @ullamco_f6 OUT, 'ticket_form.end_user_conditions[i].ullamco_f6'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'ticket_form.restricted_brand_ids'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ticket_form.restricted_brand_ids[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'ticket_form.ticket_field_ids'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ticket_form.ticket_field_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/ticket_forms/:ticket_form_id
Postman Collection Item JSON
{
"name": "Show Ticket Form",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_forms/:ticket_form_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
":ticket_form_id"
],
"variable": [
{
"key": "ticket_form_id",
"value": "<integer>"
}
]
},
"description": "#### Allowed For\n\n* Admins, Agents, and 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/ticket_forms/:ticket_form_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
":ticket_form_id"
],
"variable": [
{
"key": "ticket_form_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"ticket_form\": {\n \"name\": \"<string>\",\n \"active\": \"<boolean>\",\n \"agent_conditions\": [\n {\n \"aliqua6\": \"proident deserunt\",\n \"Lorem_d\": \"cillum dolor Excepteur ut\",\n \"mollit_cf\": -33059877,\n \"ullamco_f7\": \"dolore occaeca\"\n },\n {\n \"consequate_\": 29214347.18513973,\n \"consectetur_00\": 83697330,\n \"laborum50\": \"cillum Ut\"\n }\n ],\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"display_name\": \"<string>\",\n \"end_user_conditions\": [\n {\n \"irure__c\": false,\n \"Excepteur_38\": -15203265.607602075,\n \"sunt_8\": \"culpa laboris Ut\"\n },\n {\n \"nulla_48\": \"quis esse\",\n \"ullamco_f6\": -25516091.19614251\n }\n ],\n \"end_user_visible\": \"<boolean>\",\n \"id\": \"<integer>\",\n \"in_all_brands\": \"<boolean>\",\n \"position\": \"<integer>\",\n \"raw_display_name\": \"<string>\",\n \"raw_name\": \"<string>\",\n \"restricted_brand_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"ticket_field_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}