Chilkat Online Tools

SQL Server / Cognite API v1 / Filter transformations

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

    -- Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    -- The following JSON is sent in the request body.

    -- {
    --   "filter": {
    --     "isPublic": true,
    --     "nameRegex": "voluptate irure aute",
    --     "queryRegex": "fugiat dolor",
    --     "destinationType": "dolore velit irure dolor",
    --     "conflictMode": "id officia labore nostrud dolor",
    --     "hasBlockedError": false,
    --     "cdfProjectName": "in Ut",
    --     "createdTime": {
    --       "min": 47433915,
    --       "max": 13086787
    --     },
    --     "lastUpdatedTime": {
    --       "min": 36390643,
    --       "max": -75267076
    --     }
    --   },
    --   "limit": -29037401,
    --   "cursor": "aute magna"
    -- }

    DECLARE @json int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'filter.isPublic', 1
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.nameRegex', 'voluptate irure aute'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.queryRegex', 'fugiat dolor'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.destinationType', 'dolore velit irure dolor'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.conflictMode', 'id officia labore nostrud dolor'
    EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'filter.hasBlockedError', 0
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.cdfProjectName', 'in Ut'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.min', 47433915
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.max', 13086787
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.min', 36390643
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.max', -75267076
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'limit', -29037401
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'cursor', 'aute magna'

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'content-type', 'application/json'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'api-key', '{{api-key}}'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/api/v1/projects/{{project}}/transformations/filter', 'application/json', @json
    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 @json
        RETURN
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT @iTmp0
    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    PRINT @sTmp0
    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @json


END
GO

Curl Command

curl -X POST
	-H "api-key: {{api-key}}"
	-H "content-type: application/json"
	-d '{
    "filter": {
        "isPublic": true,
        "nameRegex": "voluptate irure aute",
        "queryRegex": "fugiat dolor",
        "destinationType": "dolore velit irure dolor",
        "conflictMode": "id officia labore nostrud dolor",
        "hasBlockedError": false,
        "cdfProjectName": "in Ut",
        "createdTime": {
            "min": 47433915,
            "max": 13086787
        },
        "lastUpdatedTime": {
            "min": 36390643,
            "max": -75267076
        }
    },
    "limit": -29037401,
    "cursor": "aute magna"
}'
https://domain.com/api/v1/projects/{{project}}/transformations/filter

Postman Collection Item JSON

{
  "id": "filterTransformations",
  "name": "Filter transformations",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "transformations",
        "filter"
      ],
      "query": [
      ],
      "variable": [
      ]
    },
    "method": "POST",
    "header": [
      {
        "key": "api-key",
        "value": "{{api-key}}",
        "description": "An admin can create API keys in the Cognite console."
      },
      {
        "key": "content-type",
        "value": "application/json"
      }
    ],
    "description": "Filter transformations. Use nextCursor to paginate through the results.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"isPublic\": true,\n        \"nameRegex\": \"voluptate irure aute\",\n        \"queryRegex\": \"fugiat dolor\",\n        \"destinationType\": \"dolore velit irure dolor\",\n        \"conflictMode\": \"id officia labore nostrud dolor\",\n        \"hasBlockedError\": false,\n        \"cdfProjectName\": \"in Ut\",\n        \"createdTime\": {\n            \"min\": 47433915,\n            \"max\": 13086787\n        },\n        \"lastUpdatedTime\": {\n            \"min\": 36390643,\n            \"max\": -75267076\n        }\n    },\n    \"limit\": -29037401,\n    \"cursor\": \"aute magna\"\n}"
    }
  }
}