unicodeC / Cognite API v1 / Aggregate time series
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.
// {
// "filter": {
// "name": "et exercitation s",
// "unit": "pariatur esse qui",
// "isString": true,
// "isStep": false,
// "metadata": {},
// "assetIds": [
// 2274246036570026,
// 8922483798410046
// ],
// "assetExternalIds": [
// "proident Ut consequat in",
// "elit incididunt aliqua"
// ],
// "rootAssetIds": [
// 7714215516056826,
// 4275780546438472
// ],
// "assetSubtreeIds": [
// {
// "id": 7555548287718054
// },
// {
// "externalId": "re"
// }
// ],
// "dataSetIds": [
// {
// "id": 5946532482497628
// },
// {
// "externalId": "exercitation nisi elit"
// }
// ],
// "externalIdPrefix": "aute Ut nostrud commodo in",
// "createdTime": {
// "max": 16041500,
// "min": 71538919
// },
// "lastUpdatedTime": {
// "max": 2438620,
// "min": 18087967
// }
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"filter.name",L"et exercitation s");
CkJsonObjectW_UpdateString(json,L"filter.unit",L"pariatur esse qui");
CkJsonObjectW_UpdateBool(json,L"filter.isString",TRUE);
CkJsonObjectW_UpdateBool(json,L"filter.isStep",FALSE);
CkJsonObjectW_UpdateNewObject(json,L"filter.metadata");
CkJsonObjectW_UpdateInt(json,L"filter.assetIds[0]",2274246036570026);
CkJsonObjectW_UpdateInt(json,L"filter.assetIds[1]",8922483798410046);
CkJsonObjectW_UpdateString(json,L"filter.assetExternalIds[0]",L"proident Ut consequat in");
CkJsonObjectW_UpdateString(json,L"filter.assetExternalIds[1]",L"elit incididunt aliqua");
CkJsonObjectW_UpdateInt(json,L"filter.rootAssetIds[0]",7714215516056826);
CkJsonObjectW_UpdateInt(json,L"filter.rootAssetIds[1]",4275780546438472);
CkJsonObjectW_UpdateInt(json,L"filter.assetSubtreeIds[0].id",123);
CkJsonObjectW_UpdateString(json,L"filter.assetSubtreeIds[1].externalId",L"re");
CkJsonObjectW_UpdateInt(json,L"filter.dataSetIds[0].id",123);
CkJsonObjectW_UpdateString(json,L"filter.dataSetIds[1].externalId",L"exercitation nisi elit");
CkJsonObjectW_UpdateString(json,L"filter.externalIdPrefix",L"aute Ut nostrud commodo in");
CkJsonObjectW_UpdateInt(json,L"filter.createdTime.max",16041500);
CkJsonObjectW_UpdateInt(json,L"filter.createdTime.min",71538919);
CkJsonObjectW_UpdateInt(json,L"filter.lastUpdatedTime.max",2438620);
CkJsonObjectW_UpdateInt(json,L"filter.lastUpdatedTime.min",18087967);
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}}/timeseries/aggregate",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 '{
"filter": {
"name": "et exercitation s",
"unit": "pariatur esse qui",
"isString": true,
"isStep": false,
"metadata": {},
"assetIds": [
2274246036570026,
8922483798410046
],
"assetExternalIds": [
"proident Ut consequat in",
"elit incididunt aliqua"
],
"rootAssetIds": [
7714215516056826,
4275780546438472
],
"assetSubtreeIds": [
{
"id": 7555548287718054
},
{
"externalId": "re"
}
],
"dataSetIds": [
{
"id": 5946532482497628
},
{
"externalId": "exercitation nisi elit"
}
],
"externalIdPrefix": "aute Ut nostrud commodo in",
"createdTime": {
"max": 16041500,
"min": 71538919
},
"lastUpdatedTime": {
"max": 2438620,
"min": 18087967
}
}
}'
https://domain.com/api/v1/projects/{{project}}/timeseries/aggregate
Postman Collection Item JSON
{
"id": "aggregateTimeSeries",
"name": "Aggregate time series",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"timeseries",
"aggregate"
],
"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": "Count the number of time series that match the given filter",
"body": {
"mode": "raw",
"raw": "{\n \"filter\": {\n \"name\": \"et exercitation s\",\n \"unit\": \"pariatur esse qui\",\n \"isString\": true,\n \"isStep\": false,\n \"metadata\": {},\n \"assetIds\": [\n 2274246036570026,\n 8922483798410046\n ],\n \"assetExternalIds\": [\n \"proident Ut consequat in\",\n \"elit incididunt aliqua\"\n ],\n \"rootAssetIds\": [\n 7714215516056826,\n 4275780546438472\n ],\n \"assetSubtreeIds\": [\n {\n \"id\": 7555548287718054\n },\n {\n \"externalId\": \"re\"\n }\n ],\n \"dataSetIds\": [\n {\n \"id\": 5946532482497628\n },\n {\n \"externalId\": \"exercitation nisi elit\"\n }\n ],\n \"externalIdPrefix\": \"aute Ut nostrud commodo in\",\n \"createdTime\": {\n \"max\": 16041500,\n \"min\": 71538919\n },\n \"lastUpdatedTime\": {\n \"max\": 2438620,\n \"min\": 18087967\n }\n }\n}"
}
}
}