Chilkat Online Tools

SQL Server / Cognite API v1 / Update extraction pipelines

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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.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.

    -- {
    --   "items": [
    --     {
    --       "id": 170038996366328,
    --       "update": {
    --         "externalId": {
    --           "set": "quis commodo minim incididunt et"
    --         },
    --         "name": {
    --           "set": "sed dolor Lorem in ipsum"
    --         },
    --         "description": {
    --           "set": "cillum nostrud sed"
    --         },
    --         "dataSetId": {
    --           "set": 5808835505541566
    --         },
    --         "schedule": {
    --           "set": "@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns"
    --         },
    --         "rawTables": {
    --           "add": [
    --           ],
    --           "remove": [
    --           ]
    --         },
    --         "contacts": {
    --           "set": [
    --           ]
    --         },
    --         "metadata": {
    --           "set": {}
    --         },
    --         "source": {
    --           "set": "laboris ut consectetur sint"
    --         },
    --         "documentation": {
    --           "set": "ullamco"
    --         }
    --       }
    --     },
    --     {
    --       "externalId": "ad",
    --       "update": {
    --         "externalId": {
    --           "set": "do non"
    --         },
    --         "name": {
    --           "set": "esse aliquip id dolor dolore"
    --         },
    --         "description": {
    --           "set": "sed quis occaecat"
    --         },
    --         "dataSetId": {
    --           "set": 2991526305068270
    --         },
    --         "schedule": {
    --           "set": "@every 005767486h236428466h76m27880668117h795ns97s784ns"
    --         },
    --         "rawTables": {
    --           "add": [
    --           ],
    --           "remove": [
    --           ]
    --         },
    --         "contacts": {
    --           "set": [
    --           ]
    --         },
    --         "metadata": {
    --           "add": {},
    --           "remove": [
    --           ]
    --         },
    --         "source": {
    --           "set": "aliquip eu ex"
    --         },
    --         "documentation": {
    --           "set": "ut"
    --         }
    --       }
    --     }
    --   ]
    -- }

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT

    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[0].id', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.externalId.set', 'quis commodo minim incididunt et'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.name.set', 'sed dolor Lorem in ipsum'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.description.set', 'cillum nostrud sed'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[0].update.dataSetId.set', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.schedule.set', '@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns'
    EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'items[0].update.rawTables.add'
    EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'items[0].update.rawTables.remove'
    EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'items[0].update.contacts.set'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[0].update.metadata.set'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.source.set', 'laboris ut consectetur sint'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.documentation.set', 'ullamco'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].externalId', 'ad'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.externalId.set', 'do non'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.name.set', 'esse aliquip id dolor dolore'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.description.set', 'sed quis occaecat'
    EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[1].update.dataSetId.set', 123
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.schedule.set', '@every 005767486h236428466h76m27880668117h795ns97s784ns'
    EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'items[1].update.rawTables.add'
    EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'items[1].update.rawTables.remove'
    EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'items[1].update.contacts.set'
    EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[1].update.metadata.add'
    EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'items[1].update.metadata.remove'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.source.set', 'aliquip eu ex'
    EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.documentation.set', 'ut'

    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}}/extpipes/update', '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 '{
    "items": [
        {
            "id": 170038996366328,
            "update": {
                "externalId": {
                    "set": "quis commodo minim incididunt et"
                },
                "name": {
                    "set": "sed dolor Lorem in ipsum"
                },
                "description": {
                    "set": "cillum nostrud sed"
                },
                "dataSetId": {
                    "set": 5808835505541566
                },
                "schedule": {
                    "set": "@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns"
                },
                "rawTables": {
                    "add": [],
                    "remove": []
                },
                "contacts": {
                    "set": []
                },
                "metadata": {
                    "set": {}
                },
                "source": {
                    "set": "laboris ut consectetur sint"
                },
                "documentation": {
                    "set": "ullamco"
                }
            }
        },
        {
            "externalId": "ad",
            "update": {
                "externalId": {
                    "set": "do non"
                },
                "name": {
                    "set": "esse aliquip id dolor dolore"
                },
                "description": {
                    "set": "sed quis occaecat"
                },
                "dataSetId": {
                    "set": 2991526305068270
                },
                "schedule": {
                    "set": "@every 005767486h236428466h76m27880668117h795ns97s784ns"
                },
                "rawTables": {
                    "add": [],
                    "remove": []
                },
                "contacts": {
                    "set": []
                },
                "metadata": {
                    "add": {},
                    "remove": []
                },
                "source": {
                    "set": "aliquip eu ex"
                },
                "documentation": {
                    "set": "ut"
                }
            }
        }
    ]
}'
https://domain.com/api/v1/projects/{{project}}/extpipes/update

Postman Collection Item JSON

{
  "id": "updateExtPipes",
  "name": "Update extraction pipelines",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "extpipes",
        "update"
      ],
      "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": "Update information for a list of extraction pipelines. Fields that are not included in the request, are not changed.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"items\": [\n        {\n            \"id\": 170038996366328,\n            \"update\": {\n                \"externalId\": {\n                    \"set\": \"quis commodo minim incididunt et\"\n                },\n                \"name\": {\n                    \"set\": \"sed dolor Lorem in ipsum\"\n                },\n                \"description\": {\n                    \"set\": \"cillum nostrud sed\"\n                },\n                \"dataSetId\": {\n                    \"set\": 5808835505541566\n                },\n                \"schedule\": {\n                    \"set\": \"@every 82504669750µs8427843087ns555708762us7123273s051539154us5900122us91861576391ns8us34751758067m770238ns227346276ns\"\n                },\n                \"rawTables\": {\n                    \"add\": [],\n                    \"remove\": []\n                },\n                \"contacts\": {\n                    \"set\": []\n                },\n                \"metadata\": {\n                    \"set\": {}\n                },\n                \"source\": {\n                    \"set\": \"laboris ut consectetur sint\"\n                },\n                \"documentation\": {\n                    \"set\": \"ullamco\"\n                }\n            }\n        },\n        {\n            \"externalId\": \"ad\",\n            \"update\": {\n                \"externalId\": {\n                    \"set\": \"do non\"\n                },\n                \"name\": {\n                    \"set\": \"esse aliquip id dolor dolore\"\n                },\n                \"description\": {\n                    \"set\": \"sed quis occaecat\"\n                },\n                \"dataSetId\": {\n                    \"set\": 2991526305068270\n                },\n                \"schedule\": {\n                    \"set\": \"@every 005767486h236428466h76m27880668117h795ns97s784ns\"\n                },\n                \"rawTables\": {\n                    \"add\": [],\n                    \"remove\": []\n                },\n                \"contacts\": {\n                    \"set\": []\n                },\n                \"metadata\": {\n                    \"add\": {},\n                    \"remove\": []\n                },\n                \"source\": {\n                    \"set\": \"aliquip eu ex\"\n                },\n                \"documentation\": {\n                    \"set\": \"ut\"\n                }\n            }\n        }\n    ]\n}"
    }
  }
}