unicodeC / Cognite API v1 / Filter relationships
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": {
// "sourceExternalIds": [
// "culpa esse veniam nisi",
// "commodo repr"
// ],
// "sourceTypes": [
// "timeSeries",
// "sequence"
// ],
// "targetExternalIds": [
// "exercitation",
// "enim culpa"
// ],
// "targetTypes": [
// "sequence",
// "timeSeries"
// ],
// "dataSetIds": [
// {
// "id": 6853944784929184
// },
// {
// "externalId": "aliquip non"
// }
// ],
// "startTime": {
// "max": 15446345,
// "min": 52529591
// },
// "endTime": {
// "max": 94684273,
// "min": 31959617
// },
// "confidence": {
// "min": 62943472.11126715,
// "max": 33071678.92549883
// },
// "lastUpdatedTime": {
// "max": 64148230,
// "min": 15602664
// },
// "createdTime": {
// "max": 99622074,
// "min": 32696551
// },
// "activeAtTime": {
// "max": 99890540,
// "min": 14084932
// },
// "labels": {
// "containsAny": [
// {
// "externalId": "et Lorem cupidatat amet"
// },
// {
// "externalId": "aliqua"
// }
// ]
// },
// "sourcesOrTargets": [
// {
// "type": "sequence",
// "externalId": "consequat id"
// }
// ]
// },
// "limit": 100,
// "cursor": "non do Excepteur dolor",
// "fetchResources": false,
// "partition": "laborum id ad cupidatat et"
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"filter.sourceExternalIds[0]",L"culpa esse veniam nisi");
CkJsonObjectW_UpdateString(json,L"filter.sourceExternalIds[1]",L"commodo repr");
CkJsonObjectW_UpdateString(json,L"filter.sourceTypes[0]",L"timeSeries");
CkJsonObjectW_UpdateString(json,L"filter.sourceTypes[1]",L"sequence");
CkJsonObjectW_UpdateString(json,L"filter.targetExternalIds[0]",L"exercitation");
CkJsonObjectW_UpdateString(json,L"filter.targetExternalIds[1]",L"enim culpa");
CkJsonObjectW_UpdateString(json,L"filter.targetTypes[0]",L"sequence");
CkJsonObjectW_UpdateString(json,L"filter.targetTypes[1]",L"timeSeries");
CkJsonObjectW_UpdateInt(json,L"filter.dataSetIds[0].id",123);
CkJsonObjectW_UpdateString(json,L"filter.dataSetIds[1].externalId",L"aliquip non");
CkJsonObjectW_UpdateInt(json,L"filter.startTime.max",15446345);
CkJsonObjectW_UpdateInt(json,L"filter.startTime.min",52529591);
CkJsonObjectW_UpdateInt(json,L"filter.endTime.max",94684273);
CkJsonObjectW_UpdateInt(json,L"filter.endTime.min",31959617);
CkJsonObjectW_UpdateNumber(json,L"filter.confidence.min",L"62943472.11126715");
CkJsonObjectW_UpdateNumber(json,L"filter.confidence.max",L"33071678.92549883");
CkJsonObjectW_UpdateInt(json,L"filter.lastUpdatedTime.max",64148230);
CkJsonObjectW_UpdateInt(json,L"filter.lastUpdatedTime.min",15602664);
CkJsonObjectW_UpdateInt(json,L"filter.createdTime.max",99622074);
CkJsonObjectW_UpdateInt(json,L"filter.createdTime.min",32696551);
CkJsonObjectW_UpdateInt(json,L"filter.activeAtTime.max",99890540);
CkJsonObjectW_UpdateInt(json,L"filter.activeAtTime.min",14084932);
CkJsonObjectW_UpdateString(json,L"filter.labels.containsAny[0].externalId",L"et Lorem cupidatat amet");
CkJsonObjectW_UpdateString(json,L"filter.labels.containsAny[1].externalId",L"aliqua");
CkJsonObjectW_UpdateString(json,L"filter.sourcesOrTargets[0].type",L"sequence");
CkJsonObjectW_UpdateString(json,L"filter.sourcesOrTargets[0].externalId",L"consequat id");
CkJsonObjectW_UpdateInt(json,L"limit",100);
CkJsonObjectW_UpdateString(json,L"cursor",L"non do Excepteur dolor");
CkJsonObjectW_UpdateBool(json,L"fetchResources",FALSE);
CkJsonObjectW_UpdateString(json,L"partition",L"laborum id ad cupidatat et");
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}}/relationships/list",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": {
"sourceExternalIds": [
"culpa esse veniam nisi",
"commodo repr"
],
"sourceTypes": [
"timeSeries",
"sequence"
],
"targetExternalIds": [
"exercitation",
"enim culpa"
],
"targetTypes": [
"sequence",
"timeSeries"
],
"dataSetIds": [
{
"id": 6853944784929184
},
{
"externalId": "aliquip non"
}
],
"startTime": {
"max": 15446345,
"min": 52529591
},
"endTime": {
"max": 94684273,
"min": 31959617
},
"confidence": {
"min": 62943472.11126715,
"max": 33071678.92549883
},
"lastUpdatedTime": {
"max": 64148230,
"min": 15602664
},
"createdTime": {
"max": 99622074,
"min": 32696551
},
"activeAtTime": {
"max": 99890540,
"min": 14084932
},
"labels": {
"containsAny": [
{
"externalId": "et Lorem cupidatat amet"
},
{
"externalId": "aliqua"
}
]
},
"sourcesOrTargets": [
{
"type": "sequence",
"externalId": "consequat id"
}
]
},
"limit": 100,
"cursor": "non do Excepteur dolor",
"fetchResources": false,
"partition": "laborum id ad cupidatat et"
}'
https://domain.com/api/v1/projects/{{project}}/relationships/list
Postman Collection Item JSON
{
"id": "listRelationships",
"name": "Filter relationships",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"relationships",
"list"
],
"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": "Lists relationships matching the query filter in the request. You can retrieve a maximum of 1000 relationships per request.",
"body": {
"mode": "raw",
"raw": "{\n \"filter\": {\n \"sourceExternalIds\": [\n \"culpa esse veniam nisi\",\n \"commodo repr\"\n ],\n \"sourceTypes\": [\n \"timeSeries\",\n \"sequence\"\n ],\n \"targetExternalIds\": [\n \"exercitation\",\n \"enim culpa\"\n ],\n \"targetTypes\": [\n \"sequence\",\n \"timeSeries\"\n ],\n \"dataSetIds\": [\n {\n \"id\": 6853944784929184\n },\n {\n \"externalId\": \"aliquip non\"\n }\n ],\n \"startTime\": {\n \"max\": 15446345,\n \"min\": 52529591\n },\n \"endTime\": {\n \"max\": 94684273,\n \"min\": 31959617\n },\n \"confidence\": {\n \"min\": 62943472.11126715,\n \"max\": 33071678.92549883\n },\n \"lastUpdatedTime\": {\n \"max\": 64148230,\n \"min\": 15602664\n },\n \"createdTime\": {\n \"max\": 99622074,\n \"min\": 32696551\n },\n \"activeAtTime\": {\n \"max\": 99890540,\n \"min\": 14084932\n },\n \"labels\": {\n \"containsAny\": [\n {\n \"externalId\": \"et Lorem cupidatat amet\"\n },\n {\n \"externalId\": \"aliqua\"\n }\n ]\n },\n \"sourcesOrTargets\": [\n {\n \"type\": \"sequence\",\n \"externalId\": \"consequat id\"\n }\n ]\n },\n \"limit\": 100,\n \"cursor\": \"non do Excepteur dolor\",\n \"fetchResources\": false,\n \"partition\": \"laborum id ad cupidatat et\"\n}"
}
}
}