SQL Server / Support API / Retrieve Supported Filter Definition Items
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/olas/policies/definitions', @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)
-- {
-- "definitions": {
-- "type": "object",
-- "properties": {
-- "all": {
-- "type": "array",
-- "items": {
-- "type": "object",
-- "properties": {
-- "group": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "operators": {
-- "type": "array",
-- "items": {
-- "type": "object",
-- "properties": {
-- "title": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "value": {
-- "type": "string",
-- "default": "<string>"
-- }
-- }
-- },
-- "maxItems": 2
-- },
-- "target": {
-- "type": "string",
-- "nullable": true,
-- "default": "<string>"
-- },
-- "title": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "value": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "values": {
-- "type": "object",
-- "properties": {
-- "list": {
-- "type": "array",
-- "items": {
-- "type": "object",
-- "properties": {
-- "title": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "value": {
-- "type": "string",
-- "nullable": true,
-- "default": "<string>"
-- }
-- }
-- },
-- "maxItems": 2
-- },
-- "type": {
-- "type": "string",
-- "default": "<string>"
-- }
-- }
-- }
-- }
-- },
-- "maxItems": 2
-- },
-- "any": {
-- "type": "array",
-- "items": {
-- "type": "object",
-- "properties": {
-- "group": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "operators": {
-- "type": "array",
-- "items": {
-- "type": "object",
-- "properties": {
-- "title": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "value": {
-- "type": "string",
-- "default": "<string>"
-- }
-- }
-- },
-- "maxItems": 2
-- },
-- "target": {
-- "type": "string",
-- "nullable": true,
-- "default": "<string>"
-- },
-- "title": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "value": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "values": {
-- "type": "object",
-- "properties": {
-- "list": {
-- "type": "array",
-- "items": {
-- "type": "object",
-- "properties": {
-- "title": {
-- "type": "string",
-- "default": "<string>"
-- },
-- "value": {
-- "type": "string",
-- "nullable": true,
-- "default": "<string>"
-- }
-- }
-- },
-- "maxItems": 2
-- },
-- "type": {
-- "type": "string",
-- "default": "<string>"
-- }
-- }
-- }
-- }
-- },
-- "maxItems": 2
-- }
-- }
-- }
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @v_Type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'definitions.type'
DECLARE @AllType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @AllType OUT, 'definitions.properties.all.type'
DECLARE @ItemsType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ItemsType OUT, 'definitions.properties.all.items.type'
DECLARE @GroupType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @GroupType OUT, 'definitions.properties.all.items.properties.group.type'
DECLARE @Default nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Default OUT, 'definitions.properties.all.items.properties.group.default'
DECLARE @OperatorsType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @OperatorsType OUT, 'definitions.properties.all.items.properties.operators.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ItemsType OUT, 'definitions.properties.all.items.properties.operators.items.type'
DECLARE @TitleType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TitleType OUT, 'definitions.properties.all.items.properties.operators.items.properties.title.type'
DECLARE @TitleDefault nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TitleDefault OUT, 'definitions.properties.all.items.properties.operators.items.properties.title.default'
DECLARE @ValueType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueType OUT, 'definitions.properties.all.items.properties.operators.items.properties.value.type'
DECLARE @ValueDefault nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValueDefault OUT, 'definitions.properties.all.items.properties.operators.items.properties.value.default'
DECLARE @MaxItems int
EXEC sp_OAMethod @jResp, 'IntOf', @MaxItems OUT, 'definitions.properties.all.items.properties.operators.maxItems'
DECLARE @TargetType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TargetType OUT, 'definitions.properties.all.items.properties.target.type'
DECLARE @Nullable int
EXEC sp_OAMethod @jResp, 'BoolOf', @Nullable OUT, 'definitions.properties.all.items.properties.target.nullable'
DECLARE @TargetDefault nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TargetDefault OUT, 'definitions.properties.all.items.properties.target.default'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleType OUT, 'definitions.properties.all.items.properties.title.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleDefault OUT, 'definitions.properties.all.items.properties.title.default'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueType OUT, 'definitions.properties.all.items.properties.value.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueDefault OUT, 'definitions.properties.all.items.properties.value.default'
DECLARE @ValuesType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ValuesType OUT, 'definitions.properties.all.items.properties.values.type'
DECLARE @ListType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ListType OUT, 'definitions.properties.all.items.properties.values.properties.list.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ItemsType OUT, 'definitions.properties.all.items.properties.values.properties.list.items.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleType OUT, 'definitions.properties.all.items.properties.values.properties.list.items.properties.title.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleDefault OUT, 'definitions.properties.all.items.properties.values.properties.list.items.properties.title.default'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueType OUT, 'definitions.properties.all.items.properties.values.properties.list.items.properties.value.type'
DECLARE @ValueNullable int
EXEC sp_OAMethod @jResp, 'BoolOf', @ValueNullable OUT, 'definitions.properties.all.items.properties.values.properties.list.items.properties.value.nullable'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueDefault OUT, 'definitions.properties.all.items.properties.values.properties.list.items.properties.value.default'
DECLARE @ListMaxItems int
EXEC sp_OAMethod @jResp, 'IntOf', @ListMaxItems OUT, 'definitions.properties.all.items.properties.values.properties.list.maxItems'
DECLARE @TypeType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TypeType OUT, 'definitions.properties.all.items.properties.values.properties.type.type'
DECLARE @TypeDefault nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @TypeDefault OUT, 'definitions.properties.all.items.properties.values.properties.type.default'
DECLARE @AllMaxItems int
EXEC sp_OAMethod @jResp, 'IntOf', @AllMaxItems OUT, 'definitions.properties.all.maxItems'
DECLARE @AnyType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @AnyType OUT, 'definitions.properties.any.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ItemsType OUT, 'definitions.properties.any.items.type'
EXEC sp_OAMethod @jResp, 'StringOf', @GroupType OUT, 'definitions.properties.any.items.properties.group.type'
DECLARE @GroupDefault nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @GroupDefault OUT, 'definitions.properties.any.items.properties.group.default'
EXEC sp_OAMethod @jResp, 'StringOf', @OperatorsType OUT, 'definitions.properties.any.items.properties.operators.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ItemsType OUT, 'definitions.properties.any.items.properties.operators.items.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleType OUT, 'definitions.properties.any.items.properties.operators.items.properties.title.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleDefault OUT, 'definitions.properties.any.items.properties.operators.items.properties.title.default'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueType OUT, 'definitions.properties.any.items.properties.operators.items.properties.value.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueDefault OUT, 'definitions.properties.any.items.properties.operators.items.properties.value.default'
DECLARE @OperatorsMaxItems int
EXEC sp_OAMethod @jResp, 'IntOf', @OperatorsMaxItems OUT, 'definitions.properties.any.items.properties.operators.maxItems'
EXEC sp_OAMethod @jResp, 'StringOf', @TargetType OUT, 'definitions.properties.any.items.properties.target.type'
DECLARE @TargetNullable int
EXEC sp_OAMethod @jResp, 'BoolOf', @TargetNullable OUT, 'definitions.properties.any.items.properties.target.nullable'
EXEC sp_OAMethod @jResp, 'StringOf', @TargetDefault OUT, 'definitions.properties.any.items.properties.target.default'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleType OUT, 'definitions.properties.any.items.properties.title.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleDefault OUT, 'definitions.properties.any.items.properties.title.default'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueType OUT, 'definitions.properties.any.items.properties.value.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueDefault OUT, 'definitions.properties.any.items.properties.value.default'
EXEC sp_OAMethod @jResp, 'StringOf', @ValuesType OUT, 'definitions.properties.any.items.properties.values.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ListType OUT, 'definitions.properties.any.items.properties.values.properties.list.type'
EXEC sp_OAMethod @jResp, 'StringOf', @ItemsType OUT, 'definitions.properties.any.items.properties.values.properties.list.items.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleType OUT, 'definitions.properties.any.items.properties.values.properties.list.items.properties.title.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TitleDefault OUT, 'definitions.properties.any.items.properties.values.properties.list.items.properties.title.default'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueType OUT, 'definitions.properties.any.items.properties.values.properties.list.items.properties.value.type'
EXEC sp_OAMethod @jResp, 'BoolOf', @ValueNullable OUT, 'definitions.properties.any.items.properties.values.properties.list.items.properties.value.nullable'
EXEC sp_OAMethod @jResp, 'StringOf', @ValueDefault OUT, 'definitions.properties.any.items.properties.values.properties.list.items.properties.value.default'
EXEC sp_OAMethod @jResp, 'IntOf', @ListMaxItems OUT, 'definitions.properties.any.items.properties.values.properties.list.maxItems'
EXEC sp_OAMethod @jResp, 'StringOf', @TypeType OUT, 'definitions.properties.any.items.properties.values.properties.type.type'
EXEC sp_OAMethod @jResp, 'StringOf', @TypeDefault OUT, 'definitions.properties.any.items.properties.values.properties.type.default'
DECLARE @AnyMaxItems int
EXEC sp_OAMethod @jResp, 'IntOf', @AnyMaxItems OUT, 'definitions.properties.any.maxItems'
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/olas/policies/definitions
Postman Collection Item JSON
{
"name": "Retrieve Supported Filter Definition Items",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/olas/policies/definitions",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"olas",
"policies",
"definitions"
]
},
"description": "#### Allowed For\n\n* Admins\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/olas/policies/definitions",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"olas",
"policies",
"definitions"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"definitions\": {\n \"type\": \"object\",\n \"properties\": {\n \"all\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"group\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"operators\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"value\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n }\n }\n },\n \"maxItems\": 2\n },\n \"target\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"default\": \"<string>\"\n },\n \"title\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"value\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"values\": {\n \"type\": \"object\",\n \"properties\": {\n \"list\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"value\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"default\": \"<string>\"\n }\n }\n },\n \"maxItems\": 2\n },\n \"type\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n }\n }\n }\n }\n },\n \"maxItems\": 2\n },\n \"any\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"group\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"operators\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"value\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n }\n }\n },\n \"maxItems\": 2\n },\n \"target\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"default\": \"<string>\"\n },\n \"title\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"value\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"values\": {\n \"type\": \"object\",\n \"properties\": {\n \"list\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n },\n \"value\": {\n \"type\": \"string\",\n \"nullable\": true,\n \"default\": \"<string>\"\n }\n }\n },\n \"maxItems\": 2\n },\n \"type\": {\n \"type\": \"string\",\n \"default\": \"<string>\"\n }\n }\n }\n }\n },\n \"maxItems\": 2\n }\n }\n }\n}"
}
]
}