SQL Server / Cognite API v1 / Update 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.
-- {
-- "items": [
-- {
-- "update": {
-- "name": {
-- "set": "eu voluptate"
-- },
-- "destination": {
-- "set": {
-- "type": "datapoints"
-- }
-- },
-- "conflictMode": {
-- "set": "consectetur id sed sint"
-- },
-- "query": {
-- "set": "nisi "
-- },
-- "sourceOidcCredentials": {
-- "set": {
-- "clientId": "in fugiat",
-- "clientSecret": "Excepteur minim",
-- "scopes": "ullamco Ut et nostrud Duis",
-- "tokenUri": "nostrud irure enim anim",
-- "cdfProjectName": "consequat adipisicing",
-- "audience": "dolor nulla ad"
-- }
-- },
-- "destinationOidcCredentials": {
-- "setNull": true
-- },
-- "sourceApiKey": {
-- "setNull": false
-- },
-- "destinationApiKey": {
-- "setNull": true
-- },
-- "isPublic": {
-- "set": false
-- },
-- "ignoreNullFields": {
-- "set": true
-- }
-- },
-- "id": -68015575
-- },
-- {
-- "update": {
-- "name": {
-- "set": "ea fugia"
-- },
-- "destination": {
-- "set": {
-- "type": "dolor",
-- "database": "ex fugiat veniam",
-- "table": "incididunt dolor voluptate"
-- }
-- },
-- "conflictMode": {
-- "set": "in in sunt"
-- },
-- "query": {
-- "set": "a"
-- },
-- "sourceOidcCredentials": {
-- "set": {
-- "clientId": "aliqua in",
-- "clientSecret": "sit amet",
-- "scopes": "deserunt id culpa labore",
-- "tokenUri": "elit",
-- "cdfProjectName": "nostrud aliqua",
-- "audience": "in sunt mollit labore laboris"
-- }
-- },
-- "destinationOidcCredentials": {
-- "setNull": false
-- },
-- "sourceApiKey": {
-- "setNull": false
-- },
-- "destinationApiKey": {
-- "setNull": true
-- },
-- "isPublic": {
-- "set": true
-- },
-- "ignoreNullFields": {
-- "set": true
-- }
-- },
-- "externalId": "et ut amet quis deserunt"
-- }
-- ]
-- }
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, 'UpdateString', @success OUT, 'items[0].update.name.set', 'eu voluptate'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.destination.set.type', 'datapoints'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.conflictMode.set', 'consectetur id sed sint'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.query.set', 'nisi '
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.sourceOidcCredentials.set.clientId', 'in fugiat'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.sourceOidcCredentials.set.clientSecret', 'Excepteur minim'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.sourceOidcCredentials.set.scopes', 'ullamco Ut et nostrud Duis'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.sourceOidcCredentials.set.tokenUri', 'nostrud irure enim anim'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.sourceOidcCredentials.set.cdfProjectName', 'consequat adipisicing'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].update.sourceOidcCredentials.set.audience', 'dolor nulla ad'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[0].update.destinationOidcCredentials.setNull', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[0].update.sourceApiKey.setNull', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[0].update.destinationApiKey.setNull', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[0].update.isPublic.set', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[0].update.ignoreNullFields.set', 1
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[0].id', -68015575
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.name.set', 'ea fugia'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.destination.set.type', 'dolor'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.destination.set.database', 'ex fugiat veniam'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.destination.set.table', 'incididunt dolor voluptate'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.conflictMode.set', 'in in sunt'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.query.set', 'a'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.sourceOidcCredentials.set.clientId', 'aliqua in'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.sourceOidcCredentials.set.clientSecret', 'sit amet'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.sourceOidcCredentials.set.scopes', 'deserunt id culpa labore'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.sourceOidcCredentials.set.tokenUri', 'elit'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.sourceOidcCredentials.set.cdfProjectName', 'nostrud aliqua'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].update.sourceOidcCredentials.set.audience', 'in sunt mollit labore laboris'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[1].update.destinationOidcCredentials.setNull', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[1].update.sourceApiKey.setNull', 0
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[1].update.destinationApiKey.setNull', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[1].update.isPublic.set', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'items[1].update.ignoreNullFields.set', 1
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].externalId', 'et ut amet quis deserunt'
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/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": [
{
"update": {
"name": {
"set": "eu voluptate"
},
"destination": {
"set": {
"type": "datapoints"
}
},
"conflictMode": {
"set": "consectetur id sed sint"
},
"query": {
"set": "nisi "
},
"sourceOidcCredentials": {
"set": {
"clientId": "in fugiat",
"clientSecret": "Excepteur minim",
"scopes": "ullamco Ut et nostrud Duis",
"tokenUri": "nostrud irure enim anim",
"cdfProjectName": "consequat adipisicing",
"audience": "dolor nulla ad"
}
},
"destinationOidcCredentials": {
"setNull": true
},
"sourceApiKey": {
"setNull": false
},
"destinationApiKey": {
"setNull": true
},
"isPublic": {
"set": false
},
"ignoreNullFields": {
"set": true
}
},
"id": -68015575
},
{
"update": {
"name": {
"set": "ea fugia"
},
"destination": {
"set": {
"type": "dolor",
"database": "ex fugiat veniam",
"table": "incididunt dolor voluptate"
}
},
"conflictMode": {
"set": "in in sunt"
},
"query": {
"set": "a"
},
"sourceOidcCredentials": {
"set": {
"clientId": "aliqua in",
"clientSecret": "sit amet",
"scopes": "deserunt id culpa labore",
"tokenUri": "elit",
"cdfProjectName": "nostrud aliqua",
"audience": "in sunt mollit labore laboris"
}
},
"destinationOidcCredentials": {
"setNull": false
},
"sourceApiKey": {
"setNull": false
},
"destinationApiKey": {
"setNull": true
},
"isPublic": {
"set": true
},
"ignoreNullFields": {
"set": true
}
},
"externalId": "et ut amet quis deserunt"
}
]
}'
https://domain.com/api/v1/projects/{{project}}/transformations/update
Postman Collection Item JSON
{
"id": "updateTransformations",
"name": "Update transformations",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"transformations",
"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 the attributes of transformations, maximum 1000 per request.",
"body": {
"mode": "raw",
"raw": "{\n \"items\": [\n {\n \"update\": {\n \"name\": {\n \"set\": \"eu voluptate\"\n },\n \"destination\": {\n \"set\": {\n \"type\": \"datapoints\"\n }\n },\n \"conflictMode\": {\n \"set\": \"consectetur id sed sint\"\n },\n \"query\": {\n \"set\": \"nisi \"\n },\n \"sourceOidcCredentials\": {\n \"set\": {\n \"clientId\": \"in fugiat\",\n \"clientSecret\": \"Excepteur minim\",\n \"scopes\": \"ullamco Ut et nostrud Duis\",\n \"tokenUri\": \"nostrud irure enim anim\",\n \"cdfProjectName\": \"consequat adipisicing\",\n \"audience\": \"dolor nulla ad\"\n }\n },\n \"destinationOidcCredentials\": {\n \"setNull\": true\n },\n \"sourceApiKey\": {\n \"setNull\": false\n },\n \"destinationApiKey\": {\n \"setNull\": true\n },\n \"isPublic\": {\n \"set\": false\n },\n \"ignoreNullFields\": {\n \"set\": true\n }\n },\n \"id\": -68015575\n },\n {\n \"update\": {\n \"name\": {\n \"set\": \"ea fugia\"\n },\n \"destination\": {\n \"set\": {\n \"type\": \"dolor\",\n \"database\": \"ex fugiat veniam\",\n \"table\": \"incididunt dolor voluptate\"\n }\n },\n \"conflictMode\": {\n \"set\": \"in in sunt\"\n },\n \"query\": {\n \"set\": \"a\"\n },\n \"sourceOidcCredentials\": {\n \"set\": {\n \"clientId\": \"aliqua in\",\n \"clientSecret\": \"sit amet\",\n \"scopes\": \"deserunt id culpa labore\",\n \"tokenUri\": \"elit\",\n \"cdfProjectName\": \"nostrud aliqua\",\n \"audience\": \"in sunt mollit labore laboris\"\n }\n },\n \"destinationOidcCredentials\": {\n \"setNull\": false\n },\n \"sourceApiKey\": {\n \"setNull\": false\n },\n \"destinationApiKey\": {\n \"setNull\": true\n },\n \"isPublic\": {\n \"set\": true\n },\n \"ignoreNullFields\": {\n \"set\": true\n }\n },\n \"externalId\": \"et ut amet quis deserunt\"\n }\n ]\n}"
}
}
}