Chilkat Online Tools

DataFlex / Cognite API v1 / Aggregate files

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": "irure sed",
    //     "directoryPrefix": "nostrud consequat",
    //     "mimeType": "dolor laborum in in",
    //     "metadata": {},
    //     "assetIds": [
    //       7799666741900608,
    //       6644214122015698
    //     ],
    //     "assetExternalIds": [
    //       "quis voluptate laborum veniam",
    //       "aute ut"
    //     ],
    //     "rootAssetIds": [
    //       {
    //         "id": 6254098074953880
    //       },
    //       {
    //         "id": 8976017818812302
    //       }
    //     ],
    //     "dataSetIds": [
    //       {
    //         "externalId": "aliquip pariatur culpa cillum laborum"
    //       },
    //       {
    //         "id": 7695765338479954
    //       }
    //     ],
    //     "assetSubtreeIds": [
    //       {
    //         "externalId": "Ut amet ex cillum"
    //       },
    //       {
    //         "externalId": "sint"
    //       }
    //     ],
    //     "source": "aute Ut",
    //     "createdTime": {
    //       "max": 56270544,
    //       "min": 57758894
    //     },
    //     "lastUpdatedTime": {
    //       "max": 52283870,
    //       "min": 91808195
    //     },
    //     "uploadedTime": {
    //       "max": 26896230,
    //       "min": 27790663
    //     },
    //     "sourceCreatedTime": {
    //       "max": 2593079,
    //       "min": 10226586
    //     },
    //     "sourceModifiedTime": {
    //       "max": 74076542,
    //       "min": 32817651
    //     },
    //     "externalIdPrefix": "aliqua eu adipisicing",
    //     "uploaded": false,
    //     "labels": {
    //       "containsAny": [
    //         {
    //           "externalId": "ad aute cupidatat mollit"
    //         },
    //         {
    //           "externalId": "ex Duis sit"
    //         }
    //       ]
    //     },
    //     "geoLocation": {
    //       "relation": "INTERSECTS",
    //       "shape": {
    //         "type": "Polygon",
    //         "coordinates": [
    //         ]
    //       }
    //     }
    //   }
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "filter.name" "irure sed" To iSuccess
    Get ComUpdateString Of hoJson "filter.directoryPrefix" "nostrud consequat" To iSuccess
    Get ComUpdateString Of hoJson "filter.mimeType" "dolor laborum in in" To iSuccess
    Get ComUpdateNewObject Of hoJson "filter.metadata" To iSuccess
    Get ComUpdateInt Of hoJson "filter.assetIds[0]" 7799666741900608 To iSuccess
    Get ComUpdateInt Of hoJson "filter.assetIds[1]" 6644214122015698 To iSuccess
    Get ComUpdateString Of hoJson "filter.assetExternalIds[0]" "quis voluptate laborum veniam" To iSuccess
    Get ComUpdateString Of hoJson "filter.assetExternalIds[1]" "aute ut" To iSuccess
    Get ComUpdateInt Of hoJson "filter.rootAssetIds[0].id" 123 To iSuccess
    Get ComUpdateInt Of hoJson "filter.rootAssetIds[1].id" 123 To iSuccess
    Get ComUpdateString Of hoJson "filter.dataSetIds[0].externalId" "aliquip pariatur culpa cillum laborum" To iSuccess
    Get ComUpdateInt Of hoJson "filter.dataSetIds[1].id" 123 To iSuccess
    Get ComUpdateString Of hoJson "filter.assetSubtreeIds[0].externalId" "Ut amet ex cillum" To iSuccess
    Get ComUpdateString Of hoJson "filter.assetSubtreeIds[1].externalId" "sint" To iSuccess
    Get ComUpdateString Of hoJson "filter.source" "aute Ut" To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.max" 56270544 To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.min" 57758894 To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.max" 52283870 To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.min" 91808195 To iSuccess
    Get ComUpdateInt Of hoJson "filter.uploadedTime.max" 26896230 To iSuccess
    Get ComUpdateInt Of hoJson "filter.uploadedTime.min" 27790663 To iSuccess
    Get ComUpdateInt Of hoJson "filter.sourceCreatedTime.max" 2593079 To iSuccess
    Get ComUpdateInt Of hoJson "filter.sourceCreatedTime.min" 10226586 To iSuccess
    Get ComUpdateInt Of hoJson "filter.sourceModifiedTime.max" 74076542 To iSuccess
    Get ComUpdateInt Of hoJson "filter.sourceModifiedTime.min" 32817651 To iSuccess
    Get ComUpdateString Of hoJson "filter.externalIdPrefix" "aliqua eu adipisicing" To iSuccess
    Get ComUpdateBool Of hoJson "filter.uploaded" False To iSuccess
    Get ComUpdateString Of hoJson "filter.labels.containsAny[0].externalId" "ad aute cupidatat mollit" To iSuccess
    Get ComUpdateString Of hoJson "filter.labels.containsAny[1].externalId" "ex Duis sit" To iSuccess
    Get ComUpdateString Of hoJson "filter.geoLocation.relation" "INTERSECTS" To iSuccess
    Get ComUpdateString Of hoJson "filter.geoLocation.shape.type" "Polygon" To iSuccess
    Get ComUpdateNewArray Of hoJson "filter.geoLocation.shape.coordinates" 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}}/files/aggregate" "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": "irure sed",
        "directoryPrefix": "nostrud consequat",
        "mimeType": "dolor laborum in in",
        "metadata": {},
        "assetIds": [
            7799666741900608,
            6644214122015698
        ],
        "assetExternalIds": [
            "quis voluptate laborum veniam",
            "aute ut"
        ],
        "rootAssetIds": [
            {
                "id": 6254098074953880
            },
            {
                "id": 8976017818812302
            }
        ],
        "dataSetIds": [
            {
                "externalId": "aliquip pariatur culpa cillum laborum"
            },
            {
                "id": 7695765338479954
            }
        ],
        "assetSubtreeIds": [
            {
                "externalId": "Ut amet ex cillum"
            },
            {
                "externalId": "sint"
            }
        ],
        "source": "aute Ut",
        "createdTime": {
            "max": 56270544,
            "min": 57758894
        },
        "lastUpdatedTime": {
            "max": 52283870,
            "min": 91808195
        },
        "uploadedTime": {
            "max": 26896230,
            "min": 27790663
        },
        "sourceCreatedTime": {
            "max": 2593079,
            "min": 10226586
        },
        "sourceModifiedTime": {
            "max": 74076542,
            "min": 32817651
        },
        "externalIdPrefix": "aliqua eu adipisicing",
        "uploaded": false,
        "labels": {
            "containsAny": [
                {
                    "externalId": "ad aute cupidatat mollit"
                },
                {
                    "externalId": "ex Duis sit"
                }
            ]
        },
        "geoLocation": {
            "relation": "INTERSECTS",
            "shape": {
                "type": "Polygon",
                "coordinates": []
            }
        }
    }
}'
https://domain.com/api/v1/projects/{{project}}/files/aggregate

Postman Collection Item JSON

{
  "id": "aggregateFiles",
  "name": "Aggregate files",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "files",
        "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": "Calculate aggregates for files, based on optional filter specification. Returns the following aggregates: `count`",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"name\": \"irure sed\",\n        \"directoryPrefix\": \"nostrud consequat\",\n        \"mimeType\": \"dolor laborum in in\",\n        \"metadata\": {},\n        \"assetIds\": [\n            7799666741900608,\n            6644214122015698\n        ],\n        \"assetExternalIds\": [\n            \"quis voluptate laborum veniam\",\n            \"aute ut\"\n        ],\n        \"rootAssetIds\": [\n            {\n                \"id\": 6254098074953880\n            },\n            {\n                \"id\": 8976017818812302\n            }\n        ],\n        \"dataSetIds\": [\n            {\n                \"externalId\": \"aliquip pariatur culpa cillum laborum\"\n            },\n            {\n                \"id\": 7695765338479954\n            }\n        ],\n        \"assetSubtreeIds\": [\n            {\n                \"externalId\": \"Ut amet ex cillum\"\n            },\n            {\n                \"externalId\": \"sint\"\n            }\n        ],\n        \"source\": \"aute Ut\",\n        \"createdTime\": {\n            \"max\": 56270544,\n            \"min\": 57758894\n        },\n        \"lastUpdatedTime\": {\n            \"max\": 52283870,\n            \"min\": 91808195\n        },\n        \"uploadedTime\": {\n            \"max\": 26896230,\n            \"min\": 27790663\n        },\n        \"sourceCreatedTime\": {\n            \"max\": 2593079,\n            \"min\": 10226586\n        },\n        \"sourceModifiedTime\": {\n            \"max\": 74076542,\n            \"min\": 32817651\n        },\n        \"externalIdPrefix\": \"aliqua eu adipisicing\",\n        \"uploaded\": false,\n        \"labels\": {\n            \"containsAny\": [\n                {\n                    \"externalId\": \"ad aute cupidatat mollit\"\n                },\n                {\n                    \"externalId\": \"ex Duis sit\"\n                }\n            ]\n        },\n        \"geoLocation\": {\n            \"relation\": \"INTERSECTS\",\n            \"shape\": {\n                \"type\": \"Polygon\",\n                \"coordinates\": []\n            }\n        }\n    }\n}"
    }
  }
}