SQL Server / Support API / Reorder Ticket Forms
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
DECLARE @iTmp0 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 @resp int
EXEC sp_OAMethod @http, 'QuickRequest', @resp OUT, 'PUT', 'https://example.zendesk.com/api/v2/ticket_forms/reorder'
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
RETURN
END
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 @resp, 'GetBodySb', @success OUT, @sbResponseBody
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 @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "ticket_forms": [
-- {
-- "name": "<string>",
-- "active": "<boolean>",
-- "agent_conditions": [
-- {
-- "adipisicing_648": -24086995
-- },
-- {
-- "veniamf": "cupida"
-- }
-- ],
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "display_name": "<string>",
-- "end_user_conditions": [
-- {
-- "in_6b8": "Ut id",
-- "magna1": -6245214
-- },
-- {
-- "pariatur1": 67097325,
-- "consectetur3": false,
-- "sed_6f0": true
-- }
-- ],
-- "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>"
-- },
-- {
-- "name": "<string>",
-- "active": "<boolean>",
-- "agent_conditions": [
-- {
-- "id9": "laborum veniam",
-- "ametb8": false
-- },
-- {
-- "ut08f": -79491980.10398532,
-- "non81": "Duis est fugiat officia consequat"
-- }
-- ],
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "display_name": "<string>",
-- "end_user_conditions": [
-- {
-- "sint1d2": "sint ex et"
-- },
-- {
-- "cupidatat_667": true,
-- "magna_d8": 64894285.255497575
-- }
-- ],
-- "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 @name nvarchar(4000)
DECLARE @active nvarchar(4000)
DECLARE @created_at nvarchar(4000)
DECLARE @default nvarchar(4000)
DECLARE @display_name nvarchar(4000)
DECLARE @end_user_visible nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @in_all_brands nvarchar(4000)
DECLARE @position nvarchar(4000)
DECLARE @raw_display_name nvarchar(4000)
DECLARE @raw_name nvarchar(4000)
DECLARE @updated_at nvarchar(4000)
DECLARE @url nvarchar(4000)
DECLARE @j int
DECLARE @count_j int
DECLARE @adipisicing_648 int
DECLARE @veniamf nvarchar(4000)
DECLARE @id9 nvarchar(4000)
DECLARE @ametb8 int
DECLARE @ut08f nvarchar(4000)
DECLARE @non81 nvarchar(4000)
DECLARE @in_6b8 nvarchar(4000)
DECLARE @magna1 int
DECLARE @pariatur1 int
DECLARE @consectetur3 int
DECLARE @sed_6f0 int
DECLARE @sint1d2 nvarchar(4000)
DECLARE @cupidatat_667 int
DECLARE @magna_d8 nvarchar(4000)
DECLARE @strVal nvarchar(4000)
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'ticket_forms'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'ticket_forms[i].name'
EXEC sp_OAMethod @jResp, 'StringOf', @active OUT, 'ticket_forms[i].active'
EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'ticket_forms[i].created_at'
EXEC sp_OAMethod @jResp, 'StringOf', @default OUT, 'ticket_forms[i].default'
EXEC sp_OAMethod @jResp, 'StringOf', @display_name OUT, 'ticket_forms[i].display_name'
EXEC sp_OAMethod @jResp, 'StringOf', @end_user_visible OUT, 'ticket_forms[i].end_user_visible'
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'ticket_forms[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @in_all_brands OUT, 'ticket_forms[i].in_all_brands'
EXEC sp_OAMethod @jResp, 'StringOf', @position OUT, 'ticket_forms[i].position'
EXEC sp_OAMethod @jResp, 'StringOf', @raw_display_name OUT, 'ticket_forms[i].raw_display_name'
EXEC sp_OAMethod @jResp, 'StringOf', @raw_name OUT, 'ticket_forms[i].raw_name'
EXEC sp_OAMethod @jResp, 'StringOf', @updated_at OUT, 'ticket_forms[i].updated_at'
EXEC sp_OAMethod @jResp, 'StringOf', @url OUT, 'ticket_forms[i].url'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ticket_forms[i].agent_conditions'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'IntOf', @adipisicing_648 OUT, 'ticket_forms[i].agent_conditions[j].adipisicing_648'
EXEC sp_OAMethod @jResp, 'StringOf', @veniamf OUT, 'ticket_forms[i].agent_conditions[j].veniamf'
EXEC sp_OAMethod @jResp, 'StringOf', @id9 OUT, 'ticket_forms[i].agent_conditions[j].id9'
EXEC sp_OAMethod @jResp, 'BoolOf', @ametb8 OUT, 'ticket_forms[i].agent_conditions[j].ametb8'
EXEC sp_OAMethod @jResp, 'StringOf', @ut08f OUT, 'ticket_forms[i].agent_conditions[j].ut08f'
EXEC sp_OAMethod @jResp, 'StringOf', @non81 OUT, 'ticket_forms[i].agent_conditions[j].non81'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ticket_forms[i].end_user_conditions'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @in_6b8 OUT, 'ticket_forms[i].end_user_conditions[j].in_6b8'
EXEC sp_OAMethod @jResp, 'IntOf', @magna1 OUT, 'ticket_forms[i].end_user_conditions[j].magna1'
EXEC sp_OAMethod @jResp, 'IntOf', @pariatur1 OUT, 'ticket_forms[i].end_user_conditions[j].pariatur1'
EXEC sp_OAMethod @jResp, 'BoolOf', @consectetur3 OUT, 'ticket_forms[i].end_user_conditions[j].consectetur3'
EXEC sp_OAMethod @jResp, 'BoolOf', @sed_6f0 OUT, 'ticket_forms[i].end_user_conditions[j].sed_6f0'
EXEC sp_OAMethod @jResp, 'StringOf', @sint1d2 OUT, 'ticket_forms[i].end_user_conditions[j].sint1d2'
EXEC sp_OAMethod @jResp, 'BoolOf', @cupidatat_667 OUT, 'ticket_forms[i].end_user_conditions[j].cupidatat_667'
EXEC sp_OAMethod @jResp, 'StringOf', @magna_d8 OUT, 'ticket_forms[i].end_user_conditions[j].magna_d8'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ticket_forms[i].restricted_brand_ids'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ticket_forms[i].restricted_brand_ids[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ticket_forms[i].ticket_field_ids'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ticket_forms[i].ticket_field_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 PUT
-H "Accept: application/json"
https://example.zendesk.com/api/v2/ticket_forms/reorder
Postman Collection Item JSON
{
"name": "Reorder Ticket Forms",
"request": {
"method": "PUT",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_forms/reorder",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
"reorder"
]
},
"description": "#### Allowed For\n* Admins\n\n#### Request Parameters\n\nYou can pass in the following parameter in the payload:\n\n| Name | Type | Comment\n| ------------------- | ------ | --------\n| ticket_form_ids | array | An array of ticket form ids. Example: \"[2, 23, 46, 50]\"\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "PUT",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/ticket_forms/reorder",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"ticket_forms",
"reorder"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"ticket_forms\": [\n {\n \"name\": \"<string>\",\n \"active\": \"<boolean>\",\n \"agent_conditions\": [\n {\n \"adipisicing_648\": -24086995\n },\n {\n \"veniamf\": \"cupida\"\n }\n ],\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"display_name\": \"<string>\",\n \"end_user_conditions\": [\n {\n \"in_6b8\": \"Ut id\",\n \"magna1\": -6245214\n },\n {\n \"pariatur1\": 67097325,\n \"consectetur3\": false,\n \"sed_6f0\": true\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 {\n \"name\": \"<string>\",\n \"active\": \"<boolean>\",\n \"agent_conditions\": [\n {\n \"id9\": \"laborum veniam\",\n \"ametb8\": false\n },\n {\n \"ut08f\": -79491980.10398532,\n \"non81\": \"Duis est fugiat officia consequat\"\n }\n ],\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"display_name\": \"<string>\",\n \"end_user_conditions\": [\n {\n \"sint1d2\": \"sint ex et\"\n },\n {\n \"cupidatat_667\": true,\n \"magna_d8\": 64894285.255497575\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 ]\n}"
}
]
}