Chilkat Online Tools

DataFlex / Cognite API v1 / Filter assets

Back to Collection Items

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // 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": "reprehenderit consequat cupidatat",
    //     "parentIds": [
    //       3870116243090848,
    //       5438517294961442
    //     ],
    //     "parentExternalIds": [
    //       "tempor dolore adipisicing enim magna",
    //       "sed cillum aliqua irure n"
    //     ],
    //     "rootIds": [
    //       {
    //         "id": 3609316313824286
    //       },
    //       {
    //         "externalId": "enim ut"
    //       }
    //     ],
    //     "assetSubtreeIds": [
    //       {
    //         "id": 4152225494743294
    //       },
    //       {
    //         "id": 3214092498108058
    //       }
    //     ],
    //     "dataSetIds": [
    //       {
    //         "externalId": "do"
    //       },
    //       {
    //         "id": 7983266347295368
    //       }
    //     ],
    //     "metadata": {},
    //     "source": "occaecat incididunt cupidatat",
    //     "createdTime": {
    //       "max": 93577224,
    //       "min": 18146228
    //     },
    //     "lastUpdatedTime": {
    //       "max": 72464336,
    //       "min": 16571729
    //     },
    //     "root": true,
    //     "externalIdPrefix": "veniam aliqua",
    //     "labels": {
    //       "containsAny": [
    //         {
    //           "externalId": "in Lorem consequat"
    //         },
    //         {
    //           "externalId": "ut enim eu"
    //         }
    //       ]
    //     }
    //   },
    //   "limit": 100,
    //   "cursor": "elit laborum cillum",
    //   "aggregatedProperties": [
    //   ],
    //   "partition": "ea"
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "filter.name" "reprehenderit consequat cupidatat" To iSuccess
    Get ComUpdateInt Of hoJson "filter.parentIds[0]" 3870116243090848 To iSuccess
    Get ComUpdateInt Of hoJson "filter.parentIds[1]" 5438517294961442 To iSuccess
    Get ComUpdateString Of hoJson "filter.parentExternalIds[0]" "tempor dolore adipisicing enim magna" To iSuccess
    Get ComUpdateString Of hoJson "filter.parentExternalIds[1]" "sed cillum aliqua irure n" To iSuccess
    Get ComUpdateInt Of hoJson "filter.rootIds[0].id" 123 To iSuccess
    Get ComUpdateString Of hoJson "filter.rootIds[1].externalId" "enim ut" To iSuccess
    Get ComUpdateInt Of hoJson "filter.assetSubtreeIds[0].id" 123 To iSuccess
    Get ComUpdateInt Of hoJson "filter.assetSubtreeIds[1].id" 123 To iSuccess
    Get ComUpdateString Of hoJson "filter.dataSetIds[0].externalId" "do" To iSuccess
    Get ComUpdateInt Of hoJson "filter.dataSetIds[1].id" 123 To iSuccess
    Get ComUpdateNewObject Of hoJson "filter.metadata" To iSuccess
    Get ComUpdateString Of hoJson "filter.source" "occaecat incididunt cupidatat" To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.max" 93577224 To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.min" 18146228 To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.max" 72464336 To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.min" 16571729 To iSuccess
    Get ComUpdateBool Of hoJson "filter.root" True To iSuccess
    Get ComUpdateString Of hoJson "filter.externalIdPrefix" "veniam aliqua" To iSuccess
    Get ComUpdateString Of hoJson "filter.labels.containsAny[0].externalId" "in Lorem consequat" To iSuccess
    Get ComUpdateString Of hoJson "filter.labels.containsAny[1].externalId" "ut enim eu" To iSuccess
    Get ComUpdateInt Of hoJson "limit" 100 To iSuccess
    Get ComUpdateString Of hoJson "cursor" "elit laborum cillum" To iSuccess
    Get ComUpdateNewArray Of hoJson "aggregatedProperties" To iSuccess
    Get ComUpdateString Of hoJson "partition" "ea" To iSuccess

    Send ComSetRequestHeader To hoHttp "content-type" "application/json"
    Send ComSetRequestHeader To hoHttp "api-key" "{{api-key}}"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://domain.com/api/v1/projects/{{project}}/assets/list" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iTemp1
    Showln iTemp1
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1
    Send Destroy of hoResp


End_Procedure

Curl Command

curl -X POST
	-H "api-key: {{api-key}}"
	-H "content-type: application/json"
	-d '{
    "filter": {
        "name": "reprehenderit consequat cupidatat",
        "parentIds": [
            3870116243090848,
            5438517294961442
        ],
        "parentExternalIds": [
            "tempor dolore adipisicing enim magna",
            "sed cillum aliqua irure n"
        ],
        "rootIds": [
            {
                "id": 3609316313824286
            },
            {
                "externalId": "enim ut"
            }
        ],
        "assetSubtreeIds": [
            {
                "id": 4152225494743294
            },
            {
                "id": 3214092498108058
            }
        ],
        "dataSetIds": [
            {
                "externalId": "do"
            },
            {
                "id": 7983266347295368
            }
        ],
        "metadata": {},
        "source": "occaecat incididunt cupidatat",
        "createdTime": {
            "max": 93577224,
            "min": 18146228
        },
        "lastUpdatedTime": {
            "max": 72464336,
            "min": 16571729
        },
        "root": true,
        "externalIdPrefix": "veniam aliqua",
        "labels": {
            "containsAny": [
                {
                    "externalId": "in Lorem consequat"
                },
                {
                    "externalId": "ut enim eu"
                }
            ]
        }
    },
    "limit": 100,
    "cursor": "elit laborum cillum",
    "aggregatedProperties": [],
    "partition": "ea"
}'
https://domain.com/api/v1/projects/{{project}}/assets/list

Postman Collection Item JSON

{
  "id": "listAssets",
  "name": "Filter assets",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "assets",
        "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": "Use advanced filtering options to find assets.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"name\": \"reprehenderit consequat cupidatat\",\n        \"parentIds\": [\n            3870116243090848,\n            5438517294961442\n        ],\n        \"parentExternalIds\": [\n            \"tempor dolore adipisicing enim magna\",\n            \"sed cillum aliqua irure n\"\n        ],\n        \"rootIds\": [\n            {\n                \"id\": 3609316313824286\n            },\n            {\n                \"externalId\": \"enim ut\"\n            }\n        ],\n        \"assetSubtreeIds\": [\n            {\n                \"id\": 4152225494743294\n            },\n            {\n                \"id\": 3214092498108058\n            }\n        ],\n        \"dataSetIds\": [\n            {\n                \"externalId\": \"do\"\n            },\n            {\n                \"id\": 7983266347295368\n            }\n        ],\n        \"metadata\": {},\n        \"source\": \"occaecat incididunt cupidatat\",\n        \"createdTime\": {\n            \"max\": 93577224,\n            \"min\": 18146228\n        },\n        \"lastUpdatedTime\": {\n            \"max\": 72464336,\n            \"min\": 16571729\n        },\n        \"root\": true,\n        \"externalIdPrefix\": \"veniam aliqua\",\n        \"labels\": {\n            \"containsAny\": [\n                {\n                    \"externalId\": \"in Lorem consequat\"\n                },\n                {\n                    \"externalId\": \"ut enim eu\"\n                }\n            ]\n        }\n    },\n    \"limit\": 100,\n    \"cursor\": \"elit laborum cillum\",\n    \"aggregatedProperties\": [],\n    \"partition\": \"ea\"\n}"
    }
  }
}