unicodeC / Cognite API v1 / Create transformations
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// 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"
// }
// }
// ]
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"items[0].name",L"ipsum ut sed d");
CkJsonObjectW_UpdateBool(json,L"items[0].ignoreNullFields",FALSE);
CkJsonObjectW_UpdateString(json,L"items[0].externalId",L"proident eu mollit");
CkJsonObjectW_UpdateString(json,L"items[0].query",L"qui non sint ut");
CkJsonObjectW_UpdateString(json,L"items[0].destination.type",L"assets");
CkJsonObjectW_UpdateString(json,L"items[0].conflictMode",L"aliquip dolore nulla c");
CkJsonObjectW_UpdateBool(json,L"items[0].isPublic",FALSE);
CkJsonObjectW_UpdateString(json,L"items[0].sourceApiKey",L"esse dolore aliqua in");
CkJsonObjectW_UpdateString(json,L"items[0].destinationApiKey",L"nulla in tempor");
CkJsonObjectW_UpdateString(json,L"items[0].sourceOidcCredentials.clientId",L"p");
CkJsonObjectW_UpdateString(json,L"items[0].sourceOidcCredentials.clientSecret",L"amet");
CkJsonObjectW_UpdateString(json,L"items[0].sourceOidcCredentials.tokenUri",L"sit voluptate dolore ");
CkJsonObjectW_UpdateString(json,L"items[0].sourceOidcCredentials.cdfProjectName",L"aliquip velit incididunt");
CkJsonObjectW_UpdateString(json,L"items[0].sourceOidcCredentials.scopes",L"consectetur cillum");
CkJsonObjectW_UpdateString(json,L"items[0].sourceOidcCredentials.audience",L"non magna");
CkJsonObjectW_UpdateString(json,L"items[0].destinationOidcCredentials.clientId",L"est culpa");
CkJsonObjectW_UpdateString(json,L"items[0].destinationOidcCredentials.clientSecret",L"cillum exercitation");
CkJsonObjectW_UpdateString(json,L"items[0].destinationOidcCredentials.tokenUri",L"do ea sint culpa");
CkJsonObjectW_UpdateString(json,L"items[0].destinationOidcCredentials.cdfProjectName",L"officia proident");
CkJsonObjectW_UpdateString(json,L"items[0].destinationOidcCredentials.scopes",L"cupidatat Lorem elit adipisicing");
CkJsonObjectW_UpdateString(json,L"items[0].destinationOidcCredentials.audience",L"nisi veniam");
CkJsonObjectW_UpdateString(json,L"items[1].name",L"in occaecat ut");
CkJsonObjectW_UpdateBool(json,L"items[1].ignoreNullFields",FALSE);
CkJsonObjectW_UpdateString(json,L"items[1].externalId",L"magna Lorem");
CkJsonObjectW_UpdateString(json,L"items[1].query",L"cillum dolor ea");
CkJsonObjectW_UpdateString(json,L"items[1].destination.type",L"relationships");
CkJsonObjectW_UpdateString(json,L"items[1].conflictMode",L"pariatur laborum eiusmod Ut consectetur");
CkJsonObjectW_UpdateBool(json,L"items[1].isPublic",TRUE);
CkJsonObjectW_UpdateString(json,L"items[1].sourceApiKey",L"ullamco eu velit elit");
CkJsonObjectW_UpdateString(json,L"items[1].destinationApiKey",L"dolore in");
CkJsonObjectW_UpdateString(json,L"items[1].sourceOidcCredentials.clientId",L"Ut");
CkJsonObjectW_UpdateString(json,L"items[1].sourceOidcCredentials.clientSecret",L"minim commodo Lorem in");
CkJsonObjectW_UpdateString(json,L"items[1].sourceOidcCredentials.tokenUri",L"culpa ipsum aliquip pariatur");
CkJsonObjectW_UpdateString(json,L"items[1].sourceOidcCredentials.cdfProjectName",L"minim");
CkJsonObjectW_UpdateString(json,L"items[1].sourceOidcCredentials.scopes",L"deserunt cillum in non mollit");
CkJsonObjectW_UpdateString(json,L"items[1].sourceOidcCredentials.audience",L"elit ea");
CkJsonObjectW_UpdateString(json,L"items[1].destinationOidcCredentials.clientId",L"elit eu exercitation");
CkJsonObjectW_UpdateString(json,L"items[1].destinationOidcCredentials.clientSecret",L"fugiat");
CkJsonObjectW_UpdateString(json,L"items[1].destinationOidcCredentials.tokenUri",L"velit mollit");
CkJsonObjectW_UpdateString(json,L"items[1].destinationOidcCredentials.cdfProjectName",L"tempor enim exercitation voluptate dolore");
CkJsonObjectW_UpdateString(json,L"items[1].destinationOidcCredentials.scopes",L"ipsum Lorem ullamco consequat");
CkJsonObjectW_UpdateString(json,L"items[1].destinationOidcCredentials.audience",L"ullamco");
CkHttpW_SetRequestHeader(http,L"content-type",L"application/json");
CkHttpW_SetRequestHeader(http,L"api-key",L"{{api-key}}");
resp = CkHttpW_PostJson3(http,L"https://domain.com/api/v1/projects/{{project}}/transformations",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
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}"
}
}
}