unicodeC / Cognite API v1 / Create 3D revisions
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": [
// {
// "fileId": 61515356,
// "published": false,
// "rotation": [
// -53019239.474532664,
// -93390044.04179798
// ],
// "metadata": {},
// "camera": {
// "target": [
// 37611347.255532116,
// 3250125.148054078
// ],
// "position": [
// -52657505.10953469,
// 12877141.765109628
// ]
// }
// },
// {
// "fileId": -78327169,
// "published": false,
// "rotation": [
// 68722196.8050077,
// -2333724.1439721733
// ],
// "metadata": {},
// "camera": {
// "target": [
// 90393811.40333363,
// -2389888.4961474687
// ],
// "position": [
// 49903616.60856527,
// 10849620.22958082
// ]
// }
// }
// ]
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateInt(json,L"items[0].fileId",61515356);
CkJsonObjectW_UpdateBool(json,L"items[0].published",FALSE);
CkJsonObjectW_UpdateNumber(json,L"items[0].rotation[0]",L"-53019239.474532664");
CkJsonObjectW_UpdateNumber(json,L"items[0].rotation[1]",L"-93390044.04179798");
CkJsonObjectW_UpdateNewObject(json,L"items[0].metadata");
CkJsonObjectW_UpdateNumber(json,L"items[0].camera.target[0]",L"37611347.255532116");
CkJsonObjectW_UpdateNumber(json,L"items[0].camera.target[1]",L"3250125.148054078");
CkJsonObjectW_UpdateNumber(json,L"items[0].camera.position[0]",L"-52657505.10953469");
CkJsonObjectW_UpdateNumber(json,L"items[0].camera.position[1]",L"12877141.765109628");
CkJsonObjectW_UpdateInt(json,L"items[1].fileId",-78327169);
CkJsonObjectW_UpdateBool(json,L"items[1].published",FALSE);
CkJsonObjectW_UpdateNumber(json,L"items[1].rotation[0]",L"68722196.8050077");
CkJsonObjectW_UpdateNumber(json,L"items[1].rotation[1]",L"-2333724.1439721733");
CkJsonObjectW_UpdateNewObject(json,L"items[1].metadata");
CkJsonObjectW_UpdateNumber(json,L"items[1].camera.target[0]",L"90393811.40333363");
CkJsonObjectW_UpdateNumber(json,L"items[1].camera.target[1]",L"-2389888.4961474687");
CkJsonObjectW_UpdateNumber(json,L"items[1].camera.position[0]",L"49903616.60856527");
CkJsonObjectW_UpdateNumber(json,L"items[1].camera.position[1]",L"10849620.22958082");
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}}/3d/models/:modelId/revisions",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": [
{
"fileId": 61515356,
"published": false,
"rotation": [
-53019239.474532664,
-93390044.04179798
],
"metadata": {},
"camera": {
"target": [
37611347.255532116,
3250125.148054078
],
"position": [
-52657505.10953469,
12877141.765109628
]
}
},
{
"fileId": -78327169,
"published": false,
"rotation": [
68722196.8050077,
-2333724.1439721733
],
"metadata": {},
"camera": {
"target": [
90393811.40333363,
-2389888.4961474687
],
"position": [
49903616.60856527,
10849620.22958082
]
}
}
]
}'
https://domain.com/api/v1/projects/{{project}}/3d/models/:modelId/revisions
Postman Collection Item JSON
{
"id": "create3DRevisions",
"name": "Create 3D revisions",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"3d",
"models",
":modelId",
"revisions"
],
"query": [
],
"variable": [
{
"key": "modelId",
"description": "Model ID.",
"disabled": true,
"type": "number"
}
]
},
"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"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"items\": [\n {\n \"fileId\": 61515356,\n \"published\": false,\n \"rotation\": [\n -53019239.474532664,\n -93390044.04179798\n ],\n \"metadata\": {},\n \"camera\": {\n \"target\": [\n 37611347.255532116,\n 3250125.148054078\n ],\n \"position\": [\n -52657505.10953469,\n 12877141.765109628\n ]\n }\n },\n {\n \"fileId\": -78327169,\n \"published\": false,\n \"rotation\": [\n 68722196.8050077,\n -2333724.1439721733\n ],\n \"metadata\": {},\n \"camera\": {\n \"target\": [\n 90393811.40333363,\n -2389888.4961474687\n ],\n \"position\": [\n 49903616.60856527,\n 10849620.22958082\n ]\n }\n }\n ]\n}"
}
}
}