SQL Server / Cognite API v1 / Create sequences
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": [
-- {
-- "columns": [
-- {
-- "externalId": "dolore sint Ut nostrud voluptate",
-- "name": "",
-- "description": "minim labore id consectetur",
-- "valueType": "DOUBLE",
-- "metadata": {}
-- },
-- {
-- "externalId": "cillum sit",
-- "name": "laborum nostrud in",
-- "description": "id",
-- "valueType": "DOUBLE",
-- "metadata": {}
-- }
-- ],
-- "name": "dolore tempor qui ul",
-- "description": "ut sint aliquip eiusmod Duis",
-- "assetId": -23229265,
-- "externalId": "ut velit ipsum irure",
-- "metadata": {},
-- "dataSetId": 3324920627170116
-- },
-- {
-- "columns": [
-- {
-- "externalId": "sed aliquip ullamco non",
-- "name": "sit Lorem sunt ullamco enim",
-- "description": "eu qui proident ",
-- "valueType": "DOUBLE",
-- "metadata": {}
-- },
-- {
-- "externalId": "proident ex in",
-- "name": "cillum Excepteur ex laborum ipsum",
-- "description": "commodo nisi ut consequat magna",
-- "valueType": "DOUBLE",
-- "metadata": {}
-- }
-- ],
-- "name": "Exce",
-- "description": "dolor ipsum ad",
-- "assetId": -40853595,
-- "externalId": "anim dolor dolore",
-- "metadata": {},
-- "dataSetId": 4440527212504684
-- }
-- ]
-- }
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].columns[0].externalId', 'dolore sint Ut nostrud voluptate'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].columns[0].name', ''
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].columns[0].description', 'minim labore id consectetur'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].columns[0].valueType', 'DOUBLE'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[0].columns[0].metadata'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].columns[1].externalId', 'cillum sit'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].columns[1].name', 'laborum nostrud in'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].columns[1].description', 'id'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].columns[1].valueType', 'DOUBLE'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[0].columns[1].metadata'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].name', 'dolore tempor qui ul'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].description', 'ut sint aliquip eiusmod Duis'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[0].assetId', -23229265
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[0].externalId', 'ut velit ipsum irure'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[0].metadata'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[0].dataSetId', 123
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[0].externalId', 'sed aliquip ullamco non'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[0].name', 'sit Lorem sunt ullamco enim'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[0].description', 'eu qui proident '
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[0].valueType', 'DOUBLE'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[1].columns[0].metadata'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[1].externalId', 'proident ex in'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[1].name', 'cillum Excepteur ex laborum ipsum'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[1].description', 'commodo nisi ut consequat magna'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].columns[1].valueType', 'DOUBLE'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[1].columns[1].metadata'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].name', 'Exce'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].description', 'dolor ipsum ad'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[1].assetId', -40853595
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'items[1].externalId', 'anim dolor dolore'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'items[1].metadata'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'items[1].dataSetId', 123
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}}/sequences', '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": [
{
"columns": [
{
"externalId": "dolore sint Ut nostrud voluptate",
"name": "",
"description": "minim labore id consectetur",
"valueType": "DOUBLE",
"metadata": {}
},
{
"externalId": "cillum sit",
"name": "laborum nostrud in",
"description": "id",
"valueType": "DOUBLE",
"metadata": {}
}
],
"name": "dolore tempor qui ul",
"description": "ut sint aliquip eiusmod Duis",
"assetId": -23229265,
"externalId": "ut velit ipsum irure",
"metadata": {},
"dataSetId": 3324920627170116
},
{
"columns": [
{
"externalId": "sed aliquip ullamco non",
"name": "sit Lorem sunt ullamco enim",
"description": "eu qui proident ",
"valueType": "DOUBLE",
"metadata": {}
},
{
"externalId": "proident ex in",
"name": "cillum Excepteur ex laborum ipsum",
"description": "commodo nisi ut consequat magna",
"valueType": "DOUBLE",
"metadata": {}
}
],
"name": "Exce",
"description": "dolor ipsum ad",
"assetId": -40853595,
"externalId": "anim dolor dolore",
"metadata": {},
"dataSetId": 4440527212504684
}
]
}'
https://domain.com/api/v1/projects/{{project}}/sequences
Postman Collection Item JSON
{
"id": "createSequence",
"name": "Create sequences",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"sequences"
],
"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": "Create one or more sequences.",
"body": {
"mode": "raw",
"raw": "{\n \"items\": [\n {\n \"columns\": [\n {\n \"externalId\": \"dolore sint Ut nostrud voluptate\",\n \"name\": \"\",\n \"description\": \"minim labore id consectetur\",\n \"valueType\": \"DOUBLE\",\n \"metadata\": {}\n },\n {\n \"externalId\": \"cillum sit\",\n \"name\": \"laborum nostrud in\",\n \"description\": \"id\",\n \"valueType\": \"DOUBLE\",\n \"metadata\": {}\n }\n ],\n \"name\": \"dolore tempor qui ul\",\n \"description\": \"ut sint aliquip eiusmod Duis\",\n \"assetId\": -23229265,\n \"externalId\": \"ut velit ipsum irure\",\n \"metadata\": {},\n \"dataSetId\": 3324920627170116\n },\n {\n \"columns\": [\n {\n \"externalId\": \"sed aliquip ullamco non\",\n \"name\": \"sit Lorem sunt ullamco enim\",\n \"description\": \"eu qui proident \",\n \"valueType\": \"DOUBLE\",\n \"metadata\": {}\n },\n {\n \"externalId\": \"proident ex in\",\n \"name\": \"cillum Excepteur ex laborum ipsum\",\n \"description\": \"commodo nisi ut consequat magna\",\n \"valueType\": \"DOUBLE\",\n \"metadata\": {}\n }\n ],\n \"name\": \"Exce\",\n \"description\": \"dolor ipsum ad\",\n \"assetId\": -40853595,\n \"externalId\": \"anim dolor dolore\",\n \"metadata\": {},\n \"dataSetId\": 4440527212504684\n }\n ]\n}"
}
}
}