SQL Server / Cognite API v1 / Aggregate files
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- 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": [
-- ]
-- }
-- }
-- }
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.name', 'irure sed'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.directoryPrefix', 'nostrud consequat'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.mimeType', 'dolor laborum in in'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'filter.metadata'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.assetIds[0]', 7799666741900608
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.assetIds[1]', 6644214122015698
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetExternalIds[0]', 'quis voluptate laborum veniam'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetExternalIds[1]', 'aute ut'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.rootAssetIds[0].id', 123
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.rootAssetIds[1].id', 123
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.dataSetIds[0].externalId', 'aliquip pariatur culpa cillum laborum'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.dataSetIds[1].id', 123
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetSubtreeIds[0].externalId', 'Ut amet ex cillum'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetSubtreeIds[1].externalId', 'sint'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.source', 'aute Ut'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.max', 56270544
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.min', 57758894
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.max', 52283870
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.min', 91808195
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.uploadedTime.max', 26896230
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.uploadedTime.min', 27790663
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceCreatedTime.max', 2593079
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceCreatedTime.min', 10226586
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceModifiedTime.max', 74076542
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceModifiedTime.min', 32817651
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.externalIdPrefix', 'aliqua eu adipisicing'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'filter.uploaded', 0
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.labels.containsAny[0].externalId', 'ad aute cupidatat mollit'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.labels.containsAny[1].externalId', 'ex Duis sit'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.geoLocation.relation', 'INTERSECTS'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.geoLocation.shape.type', 'Polygon'
EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'filter.geoLocation.shape.coordinates'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'content-type', 'application/json'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'api-key', '{{api-key}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/api/v1/projects/{{project}}/files/aggregate', 'application/json', @json
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
END
GO
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}"
}
}
}