Chilkat Online Tools

unicodeC / Cognite API v1 / Filter sequences

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": "velit reprehenderit id deserunt",
    //     "externalIdPrefix": "nostrud incididunt sint aliquip",
    //     "metadata": {},
    //     "assetIds": [
    //       5295434090357810,
    //       2310505827163538
    //     ],
    //     "rootAssetIds": [
    //       6293934114666394,
    //       1520557351372486
    //     ],
    //     "assetSubtreeIds": [
    //       {
    //         "externalId": "aute irure exercitation id officia"
    //       },
    //       {
    //         "id": 2979756892505052
    //       }
    //     ],
    //     "createdTime": {
    //       "max": 67205762,
    //       "min": 42063152
    //     },
    //     "lastUpdatedTime": {
    //       "max": 48288157,
    //       "min": 93771532
    //     },
    //     "dataSetIds": [
    //       {
    //         "id": 4906538857069064
    //       },
    //       {
    //         "externalId": "irure"
    //       }
    //     ]
    //   },
    //   "limit": 100,
    //   "cursor": "laborum non ipsum",
    //   "partition": "magna consectetu"
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"filter.name",L"velit reprehenderit id deserunt");
    CkJsonObjectW_UpdateString(json,L"filter.externalIdPrefix",L"nostrud incididunt sint aliquip");
    CkJsonObjectW_UpdateNewObject(json,L"filter.metadata");
    CkJsonObjectW_UpdateInt(json,L"filter.assetIds[0]",5295434090357810);
    CkJsonObjectW_UpdateInt(json,L"filter.assetIds[1]",2310505827163538);
    CkJsonObjectW_UpdateInt(json,L"filter.rootAssetIds[0]",6293934114666394);
    CkJsonObjectW_UpdateInt(json,L"filter.rootAssetIds[1]",1520557351372486);
    CkJsonObjectW_UpdateString(json,L"filter.assetSubtreeIds[0].externalId",L"aute irure exercitation id officia");
    CkJsonObjectW_UpdateInt(json,L"filter.assetSubtreeIds[1].id",123);
    CkJsonObjectW_UpdateInt(json,L"filter.createdTime.max",67205762);
    CkJsonObjectW_UpdateInt(json,L"filter.createdTime.min",42063152);
    CkJsonObjectW_UpdateInt(json,L"filter.lastUpdatedTime.max",48288157);
    CkJsonObjectW_UpdateInt(json,L"filter.lastUpdatedTime.min",93771532);
    CkJsonObjectW_UpdateInt(json,L"filter.dataSetIds[0].id",123);
    CkJsonObjectW_UpdateString(json,L"filter.dataSetIds[1].externalId",L"irure");
    CkJsonObjectW_UpdateInt(json,L"limit",100);
    CkJsonObjectW_UpdateString(json,L"cursor",L"laborum non ipsum");
    CkJsonObjectW_UpdateString(json,L"partition",L"magna consectetu");

    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}}/sequences/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": {
        "name": "velit reprehenderit id deserunt",
        "externalIdPrefix": "nostrud incididunt sint aliquip",
        "metadata": {},
        "assetIds": [
            5295434090357810,
            2310505827163538
        ],
        "rootAssetIds": [
            6293934114666394,
            1520557351372486
        ],
        "assetSubtreeIds": [
            {
                "externalId": "aute irure exercitation id officia"
            },
            {
                "id": 2979756892505052
            }
        ],
        "createdTime": {
            "max": 67205762,
            "min": 42063152
        },
        "lastUpdatedTime": {
            "max": 48288157,
            "min": 93771532
        },
        "dataSetIds": [
            {
                "id": 4906538857069064
            },
            {
                "externalId": "irure"
            }
        ]
    },
    "limit": 100,
    "cursor": "laborum non ipsum",
    "partition": "magna consectetu"
}'
https://domain.com/api/v1/projects/{{project}}/sequences/list

Postman Collection Item JSON

{
  "id": "advancedListSequences",
  "name": "Filter sequences",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "sequences",
        "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": "Retrieves a list of sequences matching the given criteria.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"name\": \"velit reprehenderit id deserunt\",\n        \"externalIdPrefix\": \"nostrud incididunt sint aliquip\",\n        \"metadata\": {},\n        \"assetIds\": [\n            5295434090357810,\n            2310505827163538\n        ],\n        \"rootAssetIds\": [\n            6293934114666394,\n            1520557351372486\n        ],\n        \"assetSubtreeIds\": [\n            {\n                \"externalId\": \"aute irure exercitation id officia\"\n            },\n            {\n                \"id\": 2979756892505052\n            }\n        ],\n        \"createdTime\": {\n            \"max\": 67205762,\n            \"min\": 42063152\n        },\n        \"lastUpdatedTime\": {\n            \"max\": 48288157,\n            \"min\": 93771532\n        },\n        \"dataSetIds\": [\n            {\n                \"id\": 4906538857069064\n            },\n            {\n                \"externalId\": \"irure\"\n            }\n        ]\n    },\n    \"limit\": 100,\n    \"cursor\": \"laborum non ipsum\",\n    \"partition\": \"magna consectetu\"\n}"
    }
  }
}