Chilkat Online Tools

Objective-C / Cognite API v1 / Create sequences

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;

// 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
//     }
//   ]
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"items[0].columns[0].externalId" value: @"dolore sint Ut nostrud voluptate"];
[json UpdateString: @"items[0].columns[0].name" value: @""];
[json UpdateString: @"items[0].columns[0].description" value: @"minim labore id consectetur"];
[json UpdateString: @"items[0].columns[0].valueType" value: @"DOUBLE"];
[json UpdateNewObject: @"items[0].columns[0].metadata"];
[json UpdateString: @"items[0].columns[1].externalId" value: @"cillum sit"];
[json UpdateString: @"items[0].columns[1].name" value: @"laborum nostrud in"];
[json UpdateString: @"items[0].columns[1].description" value: @"id"];
[json UpdateString: @"items[0].columns[1].valueType" value: @"DOUBLE"];
[json UpdateNewObject: @"items[0].columns[1].metadata"];
[json UpdateString: @"items[0].name" value: @"dolore tempor qui ul"];
[json UpdateString: @"items[0].description" value: @"ut sint aliquip eiusmod Duis"];
[json UpdateInt: @"items[0].assetId" value: [NSNumber numberWithInt: -23229265]];
[json UpdateString: @"items[0].externalId" value: @"ut velit ipsum irure"];
[json UpdateNewObject: @"items[0].metadata"];
[json UpdateInt: @"items[0].dataSetId" value: [NSNumber numberWithInt: 123]];
[json UpdateString: @"items[1].columns[0].externalId" value: @"sed aliquip ullamco non"];
[json UpdateString: @"items[1].columns[0].name" value: @"sit Lorem sunt ullamco enim"];
[json UpdateString: @"items[1].columns[0].description" value: @"eu qui proident "];
[json UpdateString: @"items[1].columns[0].valueType" value: @"DOUBLE"];
[json UpdateNewObject: @"items[1].columns[0].metadata"];
[json UpdateString: @"items[1].columns[1].externalId" value: @"proident ex in"];
[json UpdateString: @"items[1].columns[1].name" value: @"cillum Excepteur ex laborum ipsum"];
[json UpdateString: @"items[1].columns[1].description" value: @"commodo nisi ut consequat magna"];
[json UpdateString: @"items[1].columns[1].valueType" value: @"DOUBLE"];
[json UpdateNewObject: @"items[1].columns[1].metadata"];
[json UpdateString: @"items[1].name" value: @"Exce"];
[json UpdateString: @"items[1].description" value: @"dolor ipsum ad"];
[json UpdateInt: @"items[1].assetId" value: [NSNumber numberWithInt: -40853595]];
[json UpdateString: @"items[1].externalId" value: @"anim dolor dolore"];
[json UpdateNewObject: @"items[1].metadata"];
[json UpdateInt: @"items[1].dataSetId" value: [NSNumber numberWithInt: 123]];

[http SetRequestHeader: @"content-type" value: @"application/json"];
[http SetRequestHeader: @"api-key" value: @"{{api-key}}"];

CkoHttpResponse *resp = [http PostJson3: @"https://domain.com/api/v1/projects/{{project}}/sequences" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

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}"
    }
  }
}