unicodeC / Cognite API v1 / Update 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": [
// {
// "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"
// }
// ]
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"items[0].update.name.set",L"eu voluptate");
CkJsonObjectW_UpdateString(json,L"items[0].update.destination.set.type",L"datapoints");
CkJsonObjectW_UpdateString(json,L"items[0].update.conflictMode.set",L"consectetur id sed sint");
CkJsonObjectW_UpdateString(json,L"items[0].update.query.set",L"nisi ");
CkJsonObjectW_UpdateString(json,L"items[0].update.sourceOidcCredentials.set.clientId",L"in fugiat");
CkJsonObjectW_UpdateString(json,L"items[0].update.sourceOidcCredentials.set.clientSecret",L"Excepteur minim");
CkJsonObjectW_UpdateString(json,L"items[0].update.sourceOidcCredentials.set.scopes",L"ullamco Ut et nostrud Duis");
CkJsonObjectW_UpdateString(json,L"items[0].update.sourceOidcCredentials.set.tokenUri",L"nostrud irure enim anim");
CkJsonObjectW_UpdateString(json,L"items[0].update.sourceOidcCredentials.set.cdfProjectName",L"consequat adipisicing");
CkJsonObjectW_UpdateString(json,L"items[0].update.sourceOidcCredentials.set.audience",L"dolor nulla ad");
CkJsonObjectW_UpdateBool(json,L"items[0].update.destinationOidcCredentials.setNull",TRUE);
CkJsonObjectW_UpdateBool(json,L"items[0].update.sourceApiKey.setNull",FALSE);
CkJsonObjectW_UpdateBool(json,L"items[0].update.destinationApiKey.setNull",TRUE);
CkJsonObjectW_UpdateBool(json,L"items[0].update.isPublic.set",FALSE);
CkJsonObjectW_UpdateBool(json,L"items[0].update.ignoreNullFields.set",TRUE);
CkJsonObjectW_UpdateInt(json,L"items[0].id",-68015575);
CkJsonObjectW_UpdateString(json,L"items[1].update.name.set",L"ea fugia");
CkJsonObjectW_UpdateString(json,L"items[1].update.destination.set.type",L"dolor");
CkJsonObjectW_UpdateString(json,L"items[1].update.destination.set.database",L"ex fugiat veniam");
CkJsonObjectW_UpdateString(json,L"items[1].update.destination.set.table",L"incididunt dolor voluptate");
CkJsonObjectW_UpdateString(json,L"items[1].update.conflictMode.set",L"in in sunt");
CkJsonObjectW_UpdateString(json,L"items[1].update.query.set",L"a");
CkJsonObjectW_UpdateString(json,L"items[1].update.sourceOidcCredentials.set.clientId",L"aliqua in");
CkJsonObjectW_UpdateString(json,L"items[1].update.sourceOidcCredentials.set.clientSecret",L"sit amet");
CkJsonObjectW_UpdateString(json,L"items[1].update.sourceOidcCredentials.set.scopes",L"deserunt id culpa labore");
CkJsonObjectW_UpdateString(json,L"items[1].update.sourceOidcCredentials.set.tokenUri",L"elit");
CkJsonObjectW_UpdateString(json,L"items[1].update.sourceOidcCredentials.set.cdfProjectName",L"nostrud aliqua");
CkJsonObjectW_UpdateString(json,L"items[1].update.sourceOidcCredentials.set.audience",L"in sunt mollit labore laboris");
CkJsonObjectW_UpdateBool(json,L"items[1].update.destinationOidcCredentials.setNull",FALSE);
CkJsonObjectW_UpdateBool(json,L"items[1].update.sourceApiKey.setNull",FALSE);
CkJsonObjectW_UpdateBool(json,L"items[1].update.destinationApiKey.setNull",TRUE);
CkJsonObjectW_UpdateBool(json,L"items[1].update.isPublic.set",TRUE);
CkJsonObjectW_UpdateBool(json,L"items[1].update.ignoreNullFields.set",TRUE);
CkJsonObjectW_UpdateString(json,L"items[1].externalId",L"et ut amet quis deserunt");
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/update",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": [
{
"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}"
}
}
}