Objective-C / Cognite API v1 / Create transformations
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": [
// {
// "name": "ipsum ut sed d",
// "ignoreNullFields": false,
// "externalId": "proident eu mollit",
// "query": "qui non sint ut",
// "destination": {
// "type": "assets"
// },
// "conflictMode": "aliquip dolore nulla c",
// "isPublic": false,
// "sourceApiKey": "esse dolore aliqua in",
// "destinationApiKey": "nulla in tempor",
// "sourceOidcCredentials": {
// "clientId": "p",
// "clientSecret": "amet",
// "tokenUri": "sit voluptate dolore ",
// "cdfProjectName": "aliquip velit incididunt",
// "scopes": "consectetur cillum",
// "audience": "non magna"
// },
// "destinationOidcCredentials": {
// "clientId": "est culpa",
// "clientSecret": "cillum exercitation",
// "tokenUri": "do ea sint culpa",
// "cdfProjectName": "officia proident",
// "scopes": "cupidatat Lorem elit adipisicing",
// "audience": "nisi veniam"
// }
// },
// {
// "name": "in occaecat ut",
// "ignoreNullFields": false,
// "externalId": "magna Lorem",
// "query": "cillum dolor ea",
// "destination": {
// "type": "relationships"
// },
// "conflictMode": "pariatur laborum eiusmod Ut consectetur",
// "isPublic": true,
// "sourceApiKey": "ullamco eu velit elit",
// "destinationApiKey": "dolore in",
// "sourceOidcCredentials": {
// "clientId": "Ut",
// "clientSecret": "minim commodo Lorem in",
// "tokenUri": "culpa ipsum aliquip pariatur",
// "cdfProjectName": "minim",
// "scopes": "deserunt cillum in non mollit",
// "audience": "elit ea"
// },
// "destinationOidcCredentials": {
// "clientId": "elit eu exercitation",
// "clientSecret": "fugiat",
// "tokenUri": "velit mollit",
// "cdfProjectName": "tempor enim exercitation voluptate dolore",
// "scopes": "ipsum Lorem ullamco consequat",
// "audience": "ullamco"
// }
// }
// ]
// }
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"items[0].name" value: @"ipsum ut sed d"];
[json UpdateBool: @"items[0].ignoreNullFields" value: NO];
[json UpdateString: @"items[0].externalId" value: @"proident eu mollit"];
[json UpdateString: @"items[0].query" value: @"qui non sint ut"];
[json UpdateString: @"items[0].destination.type" value: @"assets"];
[json UpdateString: @"items[0].conflictMode" value: @"aliquip dolore nulla c"];
[json UpdateBool: @"items[0].isPublic" value: NO];
[json UpdateString: @"items[0].sourceApiKey" value: @"esse dolore aliqua in"];
[json UpdateString: @"items[0].destinationApiKey" value: @"nulla in tempor"];
[json UpdateString: @"items[0].sourceOidcCredentials.clientId" value: @"p"];
[json UpdateString: @"items[0].sourceOidcCredentials.clientSecret" value: @"amet"];
[json UpdateString: @"items[0].sourceOidcCredentials.tokenUri" value: @"sit voluptate dolore "];
[json UpdateString: @"items[0].sourceOidcCredentials.cdfProjectName" value: @"aliquip velit incididunt"];
[json UpdateString: @"items[0].sourceOidcCredentials.scopes" value: @"consectetur cillum"];
[json UpdateString: @"items[0].sourceOidcCredentials.audience" value: @"non magna"];
[json UpdateString: @"items[0].destinationOidcCredentials.clientId" value: @"est culpa"];
[json UpdateString: @"items[0].destinationOidcCredentials.clientSecret" value: @"cillum exercitation"];
[json UpdateString: @"items[0].destinationOidcCredentials.tokenUri" value: @"do ea sint culpa"];
[json UpdateString: @"items[0].destinationOidcCredentials.cdfProjectName" value: @"officia proident"];
[json UpdateString: @"items[0].destinationOidcCredentials.scopes" value: @"cupidatat Lorem elit adipisicing"];
[json UpdateString: @"items[0].destinationOidcCredentials.audience" value: @"nisi veniam"];
[json UpdateString: @"items[1].name" value: @"in occaecat ut"];
[json UpdateBool: @"items[1].ignoreNullFields" value: NO];
[json UpdateString: @"items[1].externalId" value: @"magna Lorem"];
[json UpdateString: @"items[1].query" value: @"cillum dolor ea"];
[json UpdateString: @"items[1].destination.type" value: @"relationships"];
[json UpdateString: @"items[1].conflictMode" value: @"pariatur laborum eiusmod Ut consectetur"];
[json UpdateBool: @"items[1].isPublic" value: YES];
[json UpdateString: @"items[1].sourceApiKey" value: @"ullamco eu velit elit"];
[json UpdateString: @"items[1].destinationApiKey" value: @"dolore in"];
[json UpdateString: @"items[1].sourceOidcCredentials.clientId" value: @"Ut"];
[json UpdateString: @"items[1].sourceOidcCredentials.clientSecret" value: @"minim commodo Lorem in"];
[json UpdateString: @"items[1].sourceOidcCredentials.tokenUri" value: @"culpa ipsum aliquip pariatur"];
[json UpdateString: @"items[1].sourceOidcCredentials.cdfProjectName" value: @"minim"];
[json UpdateString: @"items[1].sourceOidcCredentials.scopes" value: @"deserunt cillum in non mollit"];
[json UpdateString: @"items[1].sourceOidcCredentials.audience" value: @"elit ea"];
[json UpdateString: @"items[1].destinationOidcCredentials.clientId" value: @"elit eu exercitation"];
[json UpdateString: @"items[1].destinationOidcCredentials.clientSecret" value: @"fugiat"];
[json UpdateString: @"items[1].destinationOidcCredentials.tokenUri" value: @"velit mollit"];
[json UpdateString: @"items[1].destinationOidcCredentials.cdfProjectName" value: @"tempor enim exercitation voluptate dolore"];
[json UpdateString: @"items[1].destinationOidcCredentials.scopes" value: @"ipsum Lorem ullamco consequat"];
[json UpdateString: @"items[1].destinationOidcCredentials.audience" value: @"ullamco"];
[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}}/transformations" 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": [
{
"name": "ipsum ut sed d",
"ignoreNullFields": false,
"externalId": "proident eu mollit",
"query": "qui non sint ut",
"destination": {
"type": "assets"
},
"conflictMode": "aliquip dolore nulla c",
"isPublic": false,
"sourceApiKey": "esse dolore aliqua in",
"destinationApiKey": "nulla in tempor",
"sourceOidcCredentials": {
"clientId": "p",
"clientSecret": "amet",
"tokenUri": "sit voluptate dolore ",
"cdfProjectName": "aliquip velit incididunt",
"scopes": "consectetur cillum",
"audience": "non magna"
},
"destinationOidcCredentials": {
"clientId": "est culpa",
"clientSecret": "cillum exercitation",
"tokenUri": "do ea sint culpa",
"cdfProjectName": "officia proident",
"scopes": "cupidatat Lorem elit adipisicing",
"audience": "nisi veniam"
}
},
{
"name": "in occaecat ut",
"ignoreNullFields": false,
"externalId": "magna Lorem",
"query": "cillum dolor ea",
"destination": {
"type": "relationships"
},
"conflictMode": "pariatur laborum eiusmod Ut consectetur",
"isPublic": true,
"sourceApiKey": "ullamco eu velit elit",
"destinationApiKey": "dolore in",
"sourceOidcCredentials": {
"clientId": "Ut",
"clientSecret": "minim commodo Lorem in",
"tokenUri": "culpa ipsum aliquip pariatur",
"cdfProjectName": "minim",
"scopes": "deserunt cillum in non mollit",
"audience": "elit ea"
},
"destinationOidcCredentials": {
"clientId": "elit eu exercitation",
"clientSecret": "fugiat",
"tokenUri": "velit mollit",
"cdfProjectName": "tempor enim exercitation voluptate dolore",
"scopes": "ipsum Lorem ullamco consequat",
"audience": "ullamco"
}
}
]
}'
https://domain.com/api/v1/projects/{{project}}/transformations
Postman Collection Item JSON
{
"id": "createTransformations",
"name": "Create transformations",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"transformations"
],
"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 a maximum of 1000 transformations per request.",
"body": {
"mode": "raw",
"raw": "{\n \"items\": [\n {\n \"name\": \"ipsum ut sed d\",\n \"ignoreNullFields\": false,\n \"externalId\": \"proident eu mollit\",\n \"query\": \"qui non sint ut\",\n \"destination\": {\n \"type\": \"assets\"\n },\n \"conflictMode\": \"aliquip dolore nulla c\",\n \"isPublic\": false,\n \"sourceApiKey\": \"esse dolore aliqua in\",\n \"destinationApiKey\": \"nulla in tempor\",\n \"sourceOidcCredentials\": {\n \"clientId\": \"p\",\n \"clientSecret\": \"amet\",\n \"tokenUri\": \"sit voluptate dolore \",\n \"cdfProjectName\": \"aliquip velit incididunt\",\n \"scopes\": \"consectetur cillum\",\n \"audience\": \"non magna\"\n },\n \"destinationOidcCredentials\": {\n \"clientId\": \"est culpa\",\n \"clientSecret\": \"cillum exercitation\",\n \"tokenUri\": \"do ea sint culpa\",\n \"cdfProjectName\": \"officia proident\",\n \"scopes\": \"cupidatat Lorem elit adipisicing\",\n \"audience\": \"nisi veniam\"\n }\n },\n {\n \"name\": \"in occaecat ut\",\n \"ignoreNullFields\": false,\n \"externalId\": \"magna Lorem\",\n \"query\": \"cillum dolor ea\",\n \"destination\": {\n \"type\": \"relationships\"\n },\n \"conflictMode\": \"pariatur laborum eiusmod Ut consectetur\",\n \"isPublic\": true,\n \"sourceApiKey\": \"ullamco eu velit elit\",\n \"destinationApiKey\": \"dolore in\",\n \"sourceOidcCredentials\": {\n \"clientId\": \"Ut\",\n \"clientSecret\": \"minim commodo Lorem in\",\n \"tokenUri\": \"culpa ipsum aliquip pariatur\",\n \"cdfProjectName\": \"minim\",\n \"scopes\": \"deserunt cillum in non mollit\",\n \"audience\": \"elit ea\"\n },\n \"destinationOidcCredentials\": {\n \"clientId\": \"elit eu exercitation\",\n \"clientSecret\": \"fugiat\",\n \"tokenUri\": \"velit mollit\",\n \"cdfProjectName\": \"tempor enim exercitation voluptate dolore\",\n \"scopes\": \"ipsum Lorem ullamco consequat\",\n \"audience\": \"ullamco\"\n }\n }\n ]\n}"
}
}
}