SQL Server / Support API / List Views
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'
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'access', '<string>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'active', '<boolean>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'group_id', '<integer>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'sort_by', '<string>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'sort_order', '<string>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Accept', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://example.zendesk.com/api/v2/views', @queryParams
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
EXEC @hr = sp_OADestroy @queryParams
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 @queryParams
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)
-- {
-- "count": "<integer>",
-- "next_page": "<string>",
-- "previous_page": "<string>",
-- "views": [
-- {
-- "active": "<boolean>",
-- "conditions": {
-- "amet_b2": "minim et Ut aliquip",
-- "pariatur_d74": true,
-- "eiusmodd7e": 16274866
-- },
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "description": "<string>",
-- "execution": {
-- "sit_bd1": -70845421.92699432,
-- "voluptated": -13477997
-- },
-- "id": "<integer>",
-- "position": "<integer>",
-- "restriction": {
-- "officia_1c": -36345253.13616539
-- },
-- "title": "<string>",
-- "updated_at": "<dateTime>"
-- },
-- {
-- "active": "<boolean>",
-- "conditions": {
-- "do_99": 75108528,
-- "aliqua_ad": true,
-- "dolore277": 23927228,
-- "labore0": "incididunt ut dolor"
-- },
-- "created_at": "<dateTime>",
-- "default": "<boolean>",
-- "description": "<string>",
-- "execution": {
-- "deserunt00": 61902530,
-- "velit_90": "consectetur in Excepteur"
-- },
-- "id": "<integer>",
-- "position": "<integer>",
-- "restriction": {
-- "dolor_58": -88642742.97884612,
-- "sed_41": "commodo ut"
-- },
-- "title": "<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 @active nvarchar(4000)
DECLARE @Amet_b2 nvarchar(4000)
DECLARE @Pariatur_d74 int
DECLARE @Eiusmodd7e int
DECLARE @created_at nvarchar(4000)
DECLARE @default nvarchar(4000)
DECLARE @description nvarchar(4000)
DECLARE @Sit_bd1 nvarchar(4000)
DECLARE @Voluptated int
DECLARE @id nvarchar(4000)
DECLARE @position nvarchar(4000)
DECLARE @Officia_1c nvarchar(4000)
DECLARE @title nvarchar(4000)
DECLARE @updated_at nvarchar(4000)
DECLARE @Do_99 int
DECLARE @Aliqua_ad int
DECLARE @Dolore277 int
DECLARE @Labore0 nvarchar(4000)
DECLARE @Deserunt00 int
DECLARE @Velit_90 nvarchar(4000)
DECLARE @Dolor_58 nvarchar(4000)
DECLARE @Sed_41 nvarchar(4000)
DECLARE @count nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @count OUT, 'count'
DECLARE @next_page nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @next_page OUT, 'next_page'
DECLARE @previous_page nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @previous_page OUT, 'previous_page'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'views'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @active OUT, 'views[i].active'
EXEC sp_OAMethod @jResp, 'StringOf', @Amet_b2 OUT, 'views[i].conditions.amet_b2'
EXEC sp_OAMethod @jResp, 'BoolOf', @Pariatur_d74 OUT, 'views[i].conditions.pariatur_d74'
EXEC sp_OAMethod @jResp, 'IntOf', @Eiusmodd7e OUT, 'views[i].conditions.eiusmodd7e'
EXEC sp_OAMethod @jResp, 'StringOf', @created_at OUT, 'views[i].created_at'
EXEC sp_OAMethod @jResp, 'StringOf', @default OUT, 'views[i].default'
EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'views[i].description'
EXEC sp_OAMethod @jResp, 'StringOf', @Sit_bd1 OUT, 'views[i].execution.sit_bd1'
EXEC sp_OAMethod @jResp, 'IntOf', @Voluptated OUT, 'views[i].execution.voluptated'
EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'views[i].id'
EXEC sp_OAMethod @jResp, 'StringOf', @position OUT, 'views[i].position'
EXEC sp_OAMethod @jResp, 'StringOf', @Officia_1c OUT, 'views[i].restriction.officia_1c'
EXEC sp_OAMethod @jResp, 'StringOf', @title OUT, 'views[i].title'
EXEC sp_OAMethod @jResp, 'StringOf', @updated_at OUT, 'views[i].updated_at'
EXEC sp_OAMethod @jResp, 'IntOf', @Do_99 OUT, 'views[i].conditions.do_99'
EXEC sp_OAMethod @jResp, 'BoolOf', @Aliqua_ad OUT, 'views[i].conditions.aliqua_ad'
EXEC sp_OAMethod @jResp, 'IntOf', @Dolore277 OUT, 'views[i].conditions.dolore277'
EXEC sp_OAMethod @jResp, 'StringOf', @Labore0 OUT, 'views[i].conditions.labore0'
EXEC sp_OAMethod @jResp, 'IntOf', @Deserunt00 OUT, 'views[i].execution.deserunt00'
EXEC sp_OAMethod @jResp, 'StringOf', @Velit_90 OUT, 'views[i].execution.velit_90'
EXEC sp_OAMethod @jResp, 'StringOf', @Dolor_58 OUT, 'views[i].restriction.dolor_58'
EXEC sp_OAMethod @jResp, 'StringOf', @Sed_41 OUT, 'views[i].restriction.sed_41'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -u login:password -G -d "access=%3Cstring%3E"
-d "active=%3Cboolean%3E"
-d "group_id=%3Cinteger%3E"
-d "sort_by=%3Cstring%3E"
-d "sort_order=%3Cstring%3E"
-H "Accept: application/json"
https://example.zendesk.com/api/v2/views
Postman Collection Item JSON
{
"name": "List Views",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/views?access=<string>&active=<boolean>&group_id=<integer>&sort_by=<string>&sort_order=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"views"
],
"query": [
{
"key": "access",
"value": "<string>",
"description": "Only views with given access. May be \"personal\", \"shared\", or \"account\""
},
{
"key": "active",
"value": "<boolean>",
"description": "Only active views if true, inactive views if false"
},
{
"key": "group_id",
"value": "<integer>",
"description": "Only views belonging to given group"
},
{
"key": "sort_by",
"value": "<string>",
"description": "Possible values are \"alphabetical\", \"created_at\", or \"updated_at\". Defaults to \"position\""
},
{
"key": "sort_order",
"value": "<string>",
"description": "One of \"asc\" or \"desc\". Defaults to \"asc\" for alphabetical and position sort, \"desc\" for all others"
}
]
},
"description": "Lists shared and personal views available to the current user.\n\n#### Sideloads\n\nThe following sideloads are supported:\n\n| Name | Will sideload\n| ---------------- | -------------\n| app_installation | The app installation that requires each view, if present\n| permissions | The permissions for each view\n\n#### Pagination\n\n- Cursor pagination (recommended, but only sorts by `created_at`)\n- Offset pagination\n\nSee [Pagination](/api-reference/introduction/pagination/).\n\nReturns a maximum of 100 records per page.\n\n#### Allowed For\n\n* Agents\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/views?access=<string>&active=<boolean>&group_id=<integer>&sort_by=<string>&sort_order=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"views"
],
"query": [
{
"key": "access",
"value": "<string>",
"description": "Only views with given access. May be \"personal\", \"shared\", or \"account\""
},
{
"key": "active",
"value": "<boolean>",
"description": "Only active views if true, inactive views if false"
},
{
"key": "group_id",
"value": "<integer>",
"description": "Only views belonging to given group"
},
{
"key": "sort_by",
"value": "<string>",
"description": "Possible values are \"alphabetical\", \"created_at\", or \"updated_at\". Defaults to \"position\""
},
{
"key": "sort_order",
"value": "<string>",
"description": "One of \"asc\" or \"desc\". Defaults to \"asc\" for alphabetical and position sort, \"desc\" for all others"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"count\": \"<integer>\",\n \"next_page\": \"<string>\",\n \"previous_page\": \"<string>\",\n \"views\": [\n {\n \"active\": \"<boolean>\",\n \"conditions\": {\n \"amet_b2\": \"minim et Ut aliquip\",\n \"pariatur_d74\": true,\n \"eiusmodd7e\": 16274866\n },\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"execution\": {\n \"sit_bd1\": -70845421.92699432,\n \"voluptated\": -13477997\n },\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"officia_1c\": -36345253.13616539\n },\n \"title\": \"<string>\",\n \"updated_at\": \"<dateTime>\"\n },\n {\n \"active\": \"<boolean>\",\n \"conditions\": {\n \"do_99\": 75108528,\n \"aliqua_ad\": true,\n \"dolore277\": 23927228,\n \"labore0\": \"incididunt ut dolor\"\n },\n \"created_at\": \"<dateTime>\",\n \"default\": \"<boolean>\",\n \"description\": \"<string>\",\n \"execution\": {\n \"deserunt00\": 61902530,\n \"velit_90\": \"consectetur in Excepteur\"\n },\n \"id\": \"<integer>\",\n \"position\": \"<integer>\",\n \"restriction\": {\n \"dolor_58\": -88642742.97884612,\n \"sed_41\": \"commodo ut\"\n },\n \"title\": \"<string>\",\n \"updated_at\": \"<dateTime>\"\n }\n ]\n}"
}
]
}