SQL Server / Support API / Show Workspace
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/workspaces/:workspace_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)
-- {
-- "workspace": {
-- "activated": "<boolean>",
-- "apps": [
-- {
-- "ad_be": true,
-- "ead07": 69455617,
-- "adipisicinga": true
-- },
-- {
-- "fugiat_e": false,
-- "dolorf7": -57129708.70016649
-- }
-- ],
-- "conditions": {
-- "all": [
-- {
-- "field": "<string>",
-- "operator": "<string>",
-- "value": "<string>"
-- },
-- {
-- "field": "<string>",
-- "operator": "<string>",
-- "value": "<string>"
-- }
-- ],
-- "any": [
-- {
-- "field": "<string>",
-- "operator": "<string>",
-- "value": "<string>"
-- },
-- {
-- "field": "<string>",
-- "operator": "<string>",
-- "value": "<string>"
-- }
-- ]
-- },
-- "created_at": "<dateTime>",
-- "description": "<string>",
-- "id": "<integer>",
-- "macro_ids": [
-- "<integer>",
-- "<integer>"
-- ],
-- "macros": [
-- "<integer>",
-- "<integer>"
-- ],
-- "position": "<integer>",
-- "prefer_workspace_app_order": "<boolean>",
-- "selected_macros": [
-- {
-- "actions": [
-- {
-- "field": "<string>",
-- "value": "<string>"
-- },
-- {
-- "field": "<string>",
-- "value": "<string>"
-- }
-- ],
-- "title": "<string>",
-- "active": "<boolean>",
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "description": "<string>",
-- "id": "<integer>",
-- "position": "<integer>",
-- "restriction": {
-- "in_f25": true,
-- "nisid81": "reprehenderit anim nostrud id",
-- "minim_886": false
-- },
-- "updated_at": "<dateTime>",
-- "url": "<string>",
-- "app_installation": "<string>",
-- "categories": "<string>",
-- "permissions": "<string>",
-- "usage_1h": "<integer>",
-- "usage_7d": "<integer>",
-- "usage_24h": "<integer>",
-- "usage_30d": "<integer>"
-- },
-- {
-- "actions": [
-- {
-- "field": "<string>",
-- "value": "<string>"
-- },
-- {
-- "field": "<string>",
-- "value": "<string>"
-- }
-- ],
-- "title": "<string>",
-- "active": "<boolean>",
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "description": "<string>",
-- "id": "<integer>",
-- "position": "<integer>",
-- "restriction": {
-- "culpa__d7": false,
-- "ad7": true,
-- "esse0": -82046233.9137964,
-- "veniam_f": -91185504
-- },
-- "updated_at": "<dateTime>",
-- "url": "<string>",
-- "app_installation": "<string>",
-- "categories": "<string>",
-- "permissions": "<string>",
-- "usage_1h": "<integer>",
-- "usage_7d": "<integer>",
-- "usage_24h": "<integer>",
-- "usage_30d": "<integer>"
-- }
-- ],
-- "ticket_form_id": "<integer>",
-- "title": "<string>",
-- "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 @ad_be int
DECLARE @ead07 int
DECLARE @adipisicinga int
DECLARE @fugiat_e int
DECLARE @dolorf7 nvarchar(4000)
DECLARE @field nvarchar(4000)
DECLARE @operator nvarchar(4000)
DECLARE @value nvarchar(4000)
DECLARE @strVal nvarchar(4000)
DECLARE @title nvarchar(4000)
DECLARE @active nvarchar(4000)
DECLARE @created_at nvarchar(4000)
DECLARE @default nvarchar(4000)
DECLARE @description nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @position nvarchar(4000)
DECLARE @In_f25 int
DECLARE @Nisid81 nvarchar(4000)
DECLARE @Minim_886 int
DECLARE @updated_at nvarchar(4000)
DECLARE @url nvarchar(4000)
DECLARE @app_installation nvarchar(4000)
DECLARE @categories nvarchar(4000)
DECLARE @permissions nvarchar(4000)
DECLARE @usage_1h nvarchar(4000)
DECLARE @usage_7d nvarchar(4000)
DECLARE @usage_24h nvarchar(4000)
DECLARE @usage_30d nvarchar(4000)
DECLARE @Culpa__d7 int
DECLARE @Ad7 int
DECLARE @Esse0 nvarchar(4000)
DECLARE @Veniam_f int
DECLARE @j int
DECLARE @count_j int
DECLARE @Activated nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Activated OUT, 'workspace.activated'
DECLARE @Created_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Created_at OUT, 'workspace.created_at'
DECLARE @Description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'workspace.description'
DECLARE @Id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'workspace.id'
DECLARE @Position nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Position OUT, 'workspace.position'
DECLARE @Prefer_workspace_app_order nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Prefer_workspace_app_order OUT, 'workspace.prefer_workspace_app_order'
DECLARE @Ticket_form_id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Ticket_form_id OUT, 'workspace.ticket_form_id'
DECLARE @Title nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Title OUT, 'workspace.title'
DECLARE @Updated_at nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Updated_at OUT, 'workspace.updated_at'
DECLARE @v_Url nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Url OUT, 'workspace.url'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'workspace.apps'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'BoolOf', @ad_be OUT, 'workspace.apps[i].ad_be'
EXEC sp_OAMethod @jResp, 'IntOf', @ead07 OUT, 'workspace.apps[i].ead07'
EXEC sp_OAMethod @jResp, 'BoolOf', @adipisicinga OUT, 'workspace.apps[i].adipisicinga'
EXEC sp_OAMethod @jResp, 'BoolOf', @fugiat_e OUT, 'workspace.apps[i].fugiat_e'
EXEC sp_OAMethod @jResp, 'StringOf', @dolorf7 OUT, 'workspace.apps[i].dolorf7'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'workspace.conditions.all'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @field OUT, 'workspace.conditions.all[i].field'
EXEC sp_OAMethod @jResp, 'StringOf', @operator OUT, 'workspace.conditions.all[i].operator'
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'workspace.conditions.all[i].value'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'workspace.conditions.any'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @field OUT, 'workspace.conditions.any[i].field'
EXEC sp_OAMethod @jResp, 'StringOf', @operator OUT, 'workspace.conditions.any[i].operator'
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'workspace.conditions.any[i].value'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'workspace.macro_ids'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'workspace.macro_ids[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'workspace.macros'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'workspace.macros[i]'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'workspace.selected_macros'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @title OUT, 'workspace.selected_macros[i].title'
EXEC sp_OAMethod @jResp, 'StringOf', @active OUT, 'workspace.selected_macros[i].active'
EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'workspace.selected_macros[i].created_at'
EXEC sp_OAMethod @jResp, 'StringOf', @default OUT, 'workspace.selected_macros[i].default'
EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'workspace.selected_macros[i].description'
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'workspace.selected_macros[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @position OUT, 'workspace.selected_macros[i].position'
EXEC sp_OAMethod @jResp, 'BoolOf', @In_f25 OUT, 'workspace.selected_macros[i].restriction.in_f25'
EXEC sp_OAMethod @jResp, 'StringOf', @Nisid81 OUT, 'workspace.selected_macros[i].restriction.nisid81'
EXEC sp_OAMethod @jResp, 'BoolOf', @Minim_886 OUT, 'workspace.selected_macros[i].restriction.minim_886'
EXEC sp_OAMethod @jResp, 'StringOf', @updated_at OUT, 'workspace.selected_macros[i].updated_at'
EXEC sp_OAMethod @jResp, 'StringOf', @url OUT, 'workspace.selected_macros[i].url'
EXEC sp_OAMethod @jResp, 'StringOf', @app_installation OUT, 'workspace.selected_macros[i].app_installation'
EXEC sp_OAMethod @jResp, 'StringOf', @categories OUT, 'workspace.selected_macros[i].categories'
EXEC sp_OAMethod @jResp, 'StringOf', @permissions OUT, 'workspace.selected_macros[i].permissions'
EXEC sp_OAMethod @jResp, 'StringOf', @usage_1h OUT, 'workspace.selected_macros[i].usage_1h'
EXEC sp_OAMethod @jResp, 'StringOf', @usage_7d OUT, 'workspace.selected_macros[i].usage_7d'
EXEC sp_OAMethod @jResp, 'StringOf', @usage_24h OUT, 'workspace.selected_macros[i].usage_24h'
EXEC sp_OAMethod @jResp, 'StringOf', @usage_30d OUT, 'workspace.selected_macros[i].usage_30d'
EXEC sp_OAMethod @jResp, 'BoolOf', @Culpa__d7 OUT, 'workspace.selected_macros[i].restriction.culpa__d7'
EXEC sp_OAMethod @jResp, 'BoolOf', @Ad7 OUT, 'workspace.selected_macros[i].restriction.ad7'
EXEC sp_OAMethod @jResp, 'StringOf', @Esse0 OUT, 'workspace.selected_macros[i].restriction.esse0'
EXEC sp_OAMethod @jResp, 'IntOf', @Veniam_f OUT, 'workspace.selected_macros[i].restriction.veniam_f'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'workspace.selected_macros[i].actions'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @field OUT, 'workspace.selected_macros[i].actions[j].field'
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'workspace.selected_macros[i].actions[j].value'
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/workspaces/:workspace_id
Postman Collection Item JSON
{
"name": "Show Workspace",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/workspaces/:workspace_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"workspaces",
":workspace_id"
],
"variable": [
{
"key": "workspace_id",
"value": "<integer>"
}
]
},
"description": "#### Allowed For\n* Admins\n"
},
"response": [
{
"name": "Successful response",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/workspaces/:workspace_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"workspaces",
":workspace_id"
],
"variable": [
{
"key": "workspace_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"workspace\": {\n \"activated\": \"<boolean>\",\n \"apps\": [\n {\n \"ad_be\": true,\n \"ead07\": 69455617,\n \"adipisicinga\": true\n },\n {\n \"fugiat_e\": false,\n \"dolorf7\": -57129708.70016649\n }\n ],\n \"conditions\": {\n \"all\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"any\": [\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"operator\": \"<string>\",\n \"value\": \"<string>\"\n }\n ]\n },\n \"created_at\": \"<dateTime>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"macro_ids\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"macros\": [\n \"<integer>\",\n \"<integer>\"\n ],\n \"position\": \"<integer>\",\n \"prefer_workspace_app_order\": \"<boolean>\",\n \"selected_macros\": [\n {\n \"actions\": [\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"title\": \"<string>\",\n \"active\": \"<boolean>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"in_f25\": true,\n \"nisid81\": \"reprehenderit anim nostrud id\",\n \"minim_886\": false\n },\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\",\n \"app_installation\": \"<string>\",\n \"categories\": \"<string>\",\n \"permissions\": \"<string>\",\n \"usage_1h\": \"<integer>\",\n \"usage_7d\": \"<integer>\",\n \"usage_24h\": \"<integer>\",\n \"usage_30d\": \"<integer>\"\n },\n {\n \"actions\": [\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n },\n {\n \"field\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"title\": \"<string>\",\n \"active\": \"<boolean>\",\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"culpa__d7\": false,\n \"ad7\": true,\n \"esse0\": -82046233.9137964,\n \"veniam_f\": -91185504\n },\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\",\n \"app_installation\": \"<string>\",\n \"categories\": \"<string>\",\n \"permissions\": \"<string>\",\n \"usage_1h\": \"<integer>\",\n \"usage_7d\": \"<integer>\",\n \"usage_24h\": \"<integer>\",\n \"usage_30d\": \"<integer>\"\n }\n ],\n \"ticket_form_id\": \"<integer>\",\n \"title\": \"<string>\",\n \"updated_at\": \"<dateTime>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}