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": "ex nostrud consectetur",
-- "directoryPrefix": "tempor laborum ad consectetur",
-- "mimeType": "aute dolor sit Duis",
-- "metadata": {},
-- "assetIds": [
-- 467579989120294,
-- 8421974867540202
-- ],
-- "assetExternalIds": [
-- "",
-- "sint minim aliqua "
-- ],
-- "rootAssetIds": [
-- {
-- "id": 1543391847125216
-- },
-- {
-- "id": 6483833221883084
-- }
-- ],
-- "dataSetIds": [
-- {
-- "externalId": "eu aliqua dolor ea"
-- },
-- {
-- "id": 954668826986822
-- }
-- ],
-- "assetSubtreeIds": [
-- {
-- "externalId": "nisi occaecat sunt enim Ut"
-- },
-- {
-- "externalId": "anim reprehenderit ex nostrud"
-- }
-- ],
-- "source": "nulla mollit exercita",
-- "createdTime": {
-- "max": 35775661,
-- "min": 68358871
-- },
-- "lastUpdatedTime": {
-- "max": 39458190,
-- "min": 53247476
-- },
-- "uploadedTime": {
-- "max": 20009824,
-- "min": 24281615
-- },
-- "sourceCreatedTime": {
-- "max": 94237198,
-- "min": 59856114
-- },
-- "sourceModifiedTime": {
-- "max": 74319204,
-- "min": 63072110
-- },
-- "externalIdPrefix": "et",
-- "uploaded": false,
-- "labels": {
-- "containsAll": [
-- {
-- "externalId": "Ut ipsum in"
-- },
-- {
-- "externalId": "amet reprehenderit velit"
-- }
-- ]
-- },
-- "geoLocation": {
-- "relation": "WITHIN",
-- "shape": {
-- "type": "LineString",
-- "coordinates": [
-- ]
-- }
-- }
-- },
-- "partition": "proident est Duis nisi et",
-- "limit": 100,
-- "cursor": "incididunt"
-- }
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', 'ex nostrud consectetur'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.directoryPrefix', 'tempor laborum ad consectetur'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.mimeType', 'aute dolor sit Duis'
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'filter.metadata'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.assetIds[0]', 467579989120294
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.assetIds[1]', 8421974867540202
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetExternalIds[0]', ''
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetExternalIds[1]', 'sint minim aliqua '
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', 'eu aliqua dolor ea'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.dataSetIds[1].id', 123
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetSubtreeIds[0].externalId', 'nisi occaecat sunt enim Ut'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetSubtreeIds[1].externalId', 'anim reprehenderit ex nostrud'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.source', 'nulla mollit exercita'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.max', 35775661
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.min', 68358871
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.max', 39458190
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.min', 53247476
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.uploadedTime.max', 20009824
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.uploadedTime.min', 24281615
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceCreatedTime.max', 94237198
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceCreatedTime.min', 59856114
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceModifiedTime.max', 74319204
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.sourceModifiedTime.min', 63072110
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.externalIdPrefix', 'et'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'filter.uploaded', 0
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.labels.containsAll[0].externalId', 'Ut ipsum in'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.labels.containsAll[1].externalId', 'amet reprehenderit velit'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.geoLocation.relation', 'WITHIN'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.geoLocation.shape.type', 'LineString'
EXEC sp_OAMethod @json, 'UpdateNewArray', @success OUT, 'filter.geoLocation.shape.coordinates'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'partition', 'proident est Duis nisi et'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'limit', 100
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'cursor', 'incididunt'
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/list', '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": "ex nostrud consectetur",
"directoryPrefix": "tempor laborum ad consectetur",
"mimeType": "aute dolor sit Duis",
"metadata": {},
"assetIds": [
467579989120294,
8421974867540202
],
"assetExternalIds": [
"",
"sint minim aliqua "
],
"rootAssetIds": [
{
"id": 1543391847125216
},
{
"id": 6483833221883084
}
],
"dataSetIds": [
{
"externalId": "eu aliqua dolor ea"
},
{
"id": 954668826986822
}
],
"assetSubtreeIds": [
{
"externalId": "nisi occaecat sunt enim Ut"
},
{
"externalId": "anim reprehenderit ex nostrud"
}
],
"source": "nulla mollit exercita",
"createdTime": {
"max": 35775661,
"min": 68358871
},
"lastUpdatedTime": {
"max": 39458190,
"min": 53247476
},
"uploadedTime": {
"max": 20009824,
"min": 24281615
},
"sourceCreatedTime": {
"max": 94237198,
"min": 59856114
},
"sourceModifiedTime": {
"max": 74319204,
"min": 63072110
},
"externalIdPrefix": "et",
"uploaded": false,
"labels": {
"containsAll": [
{
"externalId": "Ut ipsum in"
},
{
"externalId": "amet reprehenderit velit"
}
]
},
"geoLocation": {
"relation": "WITHIN",
"shape": {
"type": "LineString",
"coordinates": []
}
}
},
"partition": "proident est Duis nisi et",
"limit": 100,
"cursor": "incididunt"
}'
https://domain.com/api/v1/projects/{{project}}/files/list
Postman Collection Item JSON
{
"id": "advancedListFiles",
"name": "Filter files",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"files",
"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 all files in a project. Criteria can be supplied to select a subset of files. This operation supports pagination with cursors.",
"body": {
"mode": "raw",
"raw": "{\n \"filter\": {\n \"name\": \"ex nostrud consectetur\",\n \"directoryPrefix\": \"tempor laborum ad consectetur\",\n \"mimeType\": \"aute dolor sit Duis\",\n \"metadata\": {},\n \"assetIds\": [\n 467579989120294,\n 8421974867540202\n ],\n \"assetExternalIds\": [\n \"\",\n \"sint minim aliqua \"\n ],\n \"rootAssetIds\": [\n {\n \"id\": 1543391847125216\n },\n {\n \"id\": 6483833221883084\n }\n ],\n \"dataSetIds\": [\n {\n \"externalId\": \"eu aliqua dolor ea\"\n },\n {\n \"id\": 954668826986822\n }\n ],\n \"assetSubtreeIds\": [\n {\n \"externalId\": \"nisi occaecat sunt enim Ut\"\n },\n {\n \"externalId\": \"anim reprehenderit ex nostrud\"\n }\n ],\n \"source\": \"nulla mollit exercita\",\n \"createdTime\": {\n \"max\": 35775661,\n \"min\": 68358871\n },\n \"lastUpdatedTime\": {\n \"max\": 39458190,\n \"min\": 53247476\n },\n \"uploadedTime\": {\n \"max\": 20009824,\n \"min\": 24281615\n },\n \"sourceCreatedTime\": {\n \"max\": 94237198,\n \"min\": 59856114\n },\n \"sourceModifiedTime\": {\n \"max\": 74319204,\n \"min\": 63072110\n },\n \"externalIdPrefix\": \"et\",\n \"uploaded\": false,\n \"labels\": {\n \"containsAll\": [\n {\n \"externalId\": \"Ut ipsum in\"\n },\n {\n \"externalId\": \"amet reprehenderit velit\"\n }\n ]\n },\n \"geoLocation\": {\n \"relation\": \"WITHIN\",\n \"shape\": {\n \"type\": \"LineString\",\n \"coordinates\": []\n }\n }\n },\n \"partition\": \"proident est Duis nisi et\",\n \"limit\": 100,\n \"cursor\": \"incididunt\"\n}"
}
}
}