Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject json;
HCkHttpResponse resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_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": {
// "startTime": {
// "max": 28954538,
// "min": 46490486
// },
// "endTime": {
// "isNull": false
// },
// "activeAtTime": {
// "max": 27359549,
// "min": 32947272
// },
// "metadata": {},
// "assetIds": [
// 4883269954114660,
// 2578912121595962
// ],
// "assetExternalIds": [
// "exercitation dolor do",
// "occaecat"
// ],
// "rootAssetIds": [
// {
// "id": 491458656026080
// },
// {
// "id": 1026689202395094
// }
// ],
// "assetSubtreeIds": [
// {
// "externalId": "laborum"
// },
// {
// "externalId": "velit Duis"
// }
// ],
// "dataSetIds": [
// {
// "externalId": "ad"
// },
// {
// "externalId": "culpa"
// }
// ],
// "source": "deserunt ut mollit anim l",
// "type": "sed nisi exercita",
// "subtype": "aliqua Ut",
// "createdTime": {
// "max": 39562876,
// "min": 1881975
// },
// "lastUpdatedTime": {
// "max": 69566439,
// "min": 58702695
// },
// "externalIdPrefix": "in Excepteur"
// },
// "search": {
// "description": "proident ut"
// },
// "limit": 100
// }
json = CkJsonObject_Create();
CkJsonObject_UpdateInt(json,"filter.startTime.max",28954538);
CkJsonObject_UpdateInt(json,"filter.startTime.min",46490486);
CkJsonObject_UpdateBool(json,"filter.endTime.isNull",FALSE);
CkJsonObject_UpdateInt(json,"filter.activeAtTime.max",27359549);
CkJsonObject_UpdateInt(json,"filter.activeAtTime.min",32947272);
CkJsonObject_UpdateNewObject(json,"filter.metadata");
CkJsonObject_UpdateInt(json,"filter.assetIds[0]",4883269954114660);
CkJsonObject_UpdateInt(json,"filter.assetIds[1]",2578912121595962);
CkJsonObject_UpdateString(json,"filter.assetExternalIds[0]","exercitation dolor do");
CkJsonObject_UpdateString(json,"filter.assetExternalIds[1]","occaecat");
CkJsonObject_UpdateInt(json,"filter.rootAssetIds[0].id",123);
CkJsonObject_UpdateInt(json,"filter.rootAssetIds[1].id",123);
CkJsonObject_UpdateString(json,"filter.assetSubtreeIds[0].externalId","laborum");
CkJsonObject_UpdateString(json,"filter.assetSubtreeIds[1].externalId","velit Duis");
CkJsonObject_UpdateString(json,"filter.dataSetIds[0].externalId","ad");
CkJsonObject_UpdateString(json,"filter.dataSetIds[1].externalId","culpa");
CkJsonObject_UpdateString(json,"filter.source","deserunt ut mollit anim l");
CkJsonObject_UpdateString(json,"filter.type","sed nisi exercita");
CkJsonObject_UpdateString(json,"filter.subtype","aliqua Ut");
CkJsonObject_UpdateInt(json,"filter.createdTime.max",39562876);
CkJsonObject_UpdateInt(json,"filter.createdTime.min",1881975);
CkJsonObject_UpdateInt(json,"filter.lastUpdatedTime.max",69566439);
CkJsonObject_UpdateInt(json,"filter.lastUpdatedTime.min",58702695);
CkJsonObject_UpdateString(json,"filter.externalIdPrefix","in Excepteur");
CkJsonObject_UpdateString(json,"search.description","proident ut");
CkJsonObject_UpdateInt(json,"limit",100);
CkHttp_SetRequestHeader(http,"content-type","application/json");
CkHttp_SetRequestHeader(http,"api-key","{{api-key}}");
resp = CkHttp_PostJson3(http,"https://domain.com/api/v1/projects/{{project}}/events/search","application/json",json);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
return;
}
printf("%d\n",CkHttpResponse_getStatusCode(resp));
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
}
Curl Command
curl -X POST
-H "api-key: {{api-key}}"
-H "content-type: application/json"
-d '{
"filter": {
"startTime": {
"max": 28954538,
"min": 46490486
},
"endTime": {
"isNull": false
},
"activeAtTime": {
"max": 27359549,
"min": 32947272
},
"metadata": {},
"assetIds": [
4883269954114660,
2578912121595962
],
"assetExternalIds": [
"exercitation dolor do",
"occaecat"
],
"rootAssetIds": [
{
"id": 491458656026080
},
{
"id": 1026689202395094
}
],
"assetSubtreeIds": [
{
"externalId": "laborum"
},
{
"externalId": "velit Duis"
}
],
"dataSetIds": [
{
"externalId": "ad"
},
{
"externalId": "culpa"
}
],
"source": "deserunt ut mollit anim l",
"type": "sed nisi exercita",
"subtype": "aliqua Ut",
"createdTime": {
"max": 39562876,
"min": 1881975
},
"lastUpdatedTime": {
"max": 69566439,
"min": 58702695
},
"externalIdPrefix": "in Excepteur"
},
"search": {
"description": "proident ut"
},
"limit": 100
}'
https://domain.com/api/v1/projects/{{project}}/events/search
Postman Collection Item JSON
{
"id": "searchEvents",
"name": "Search within events",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"events",
"search"
],
"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"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"filter\": {\n \"startTime\": {\n \"max\": 28954538,\n \"min\": 46490486\n },\n \"endTime\": {\n \"isNull\": false\n },\n \"activeAtTime\": {\n \"max\": 27359549,\n \"min\": 32947272\n },\n \"metadata\": {},\n \"assetIds\": [\n 4883269954114660,\n 2578912121595962\n ],\n \"assetExternalIds\": [\n \"exercitation dolor do\",\n \"occaecat\"\n ],\n \"rootAssetIds\": [\n {\n \"id\": 491458656026080\n },\n {\n \"id\": 1026689202395094\n }\n ],\n \"assetSubtreeIds\": [\n {\n \"externalId\": \"laborum\"\n },\n {\n \"externalId\": \"velit Duis\"\n }\n ],\n \"dataSetIds\": [\n {\n \"externalId\": \"ad\"\n },\n {\n \"externalId\": \"culpa\"\n }\n ],\n \"source\": \"deserunt ut mollit anim l\",\n \"type\": \"sed nisi exercita\",\n \"subtype\": \"aliqua Ut\",\n \"createdTime\": {\n \"max\": 39562876,\n \"min\": 1881975\n },\n \"lastUpdatedTime\": {\n \"max\": 69566439,\n \"min\": 58702695\n },\n \"externalIdPrefix\": \"in Excepteur\"\n },\n \"search\": {\n \"description\": \"proident ut\"\n },\n \"limit\": 100\n}"
}
}
}