SQL Server / Cognite API v1 / Search time series
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": "dolor eiusmod nostrud ea cillum",
-- "unit": "sint culpa voluptate",
-- "isString": true,
-- "isStep": true,
-- "metadata": {},
-- "assetIds": [
-- 8392988761056162,
-- 2911403766826494
-- ],
-- "assetExternalIds": [
-- "esse non aute",
-- "dolor in amet et minim"
-- ],
-- "rootAssetIds": [
-- 4628243625090460,
-- 3862854227867686
-- ],
-- "assetSubtreeIds": [
-- {
-- "id": 229005040467072
-- },
-- {
-- "externalId": "aute in elit aliquip"
-- }
-- ],
-- "dataSetIds": [
-- {
-- "externalId": "voluptate adipisicing ex in dolore"
-- },
-- {
-- "externalId": "irure laboris consectetur veniam velit"
-- }
-- ],
-- "externalIdPrefix": "veniam",
-- "createdTime": {
-- "max": 11556036,
-- "min": 65169412
-- },
-- "lastUpdatedTime": {
-- "max": 47360518,
-- "min": 36601806
-- }
-- },
-- "search": {
-- "name": "cupi",
-- "description": "aliqua ut mi",
-- "query": "in id fugiat"
-- },
-- "limit": 100
-- }
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', 'dolor eiusmod nostrud ea cillum'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.unit', 'sint culpa voluptate'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'filter.isString', 1
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'filter.isStep', 1
EXEC sp_OAMethod @json, 'UpdateNewObject', @success OUT, 'filter.metadata'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.assetIds[0]', 8392988761056162
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.assetIds[1]', 2911403766826494
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetExternalIds[0]', 'esse non aute'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetExternalIds[1]', 'dolor in amet et minim'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.rootAssetIds[0]', 4628243625090460
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.rootAssetIds[1]', 3862854227867686
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.assetSubtreeIds[0].id', 123
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.assetSubtreeIds[1].externalId', 'aute in elit aliquip'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.dataSetIds[0].externalId', 'voluptate adipisicing ex in dolore'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.dataSetIds[1].externalId', 'irure laboris consectetur veniam velit'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.externalIdPrefix', 'veniam'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.max', 11556036
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.min', 65169412
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.max', 47360518
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.min', 36601806
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'search.name', 'cupi'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'search.description', 'aliqua ut mi'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'search.query', 'in id fugiat'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'limit', 100
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}}/timeseries/search', '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": "dolor eiusmod nostrud ea cillum",
"unit": "sint culpa voluptate",
"isString": true,
"isStep": true,
"metadata": {},
"assetIds": [
8392988761056162,
2911403766826494
],
"assetExternalIds": [
"esse non aute",
"dolor in amet et minim"
],
"rootAssetIds": [
4628243625090460,
3862854227867686
],
"assetSubtreeIds": [
{
"id": 229005040467072
},
{
"externalId": "aute in elit aliquip"
}
],
"dataSetIds": [
{
"externalId": "voluptate adipisicing ex in dolore"
},
{
"externalId": "irure laboris consectetur veniam velit"
}
],
"externalIdPrefix": "veniam",
"createdTime": {
"max": 11556036,
"min": 65169412
},
"lastUpdatedTime": {
"max": 47360518,
"min": 36601806
}
},
"search": {
"name": "cupi",
"description": "aliqua ut mi",
"query": "in id fugiat"
},
"limit": 100
}'
https://domain.com/api/v1/projects/{{project}}/timeseries/search
Postman Collection Item JSON
{
"id": "searchTimeSeries",
"name": "Search time series",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"timeseries",
"search"
],
"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": "Fulltext search for time series based on result relevance. Primarily meant\nfor human-centric use-cases, not for programs, since matching and\nordering may change over time. Additional filters can also be\nspecified. This operation does not support pagination.",
"body": {
"mode": "raw",
"raw": "{\n \"filter\": {\n \"name\": \"dolor eiusmod nostrud ea cillum\",\n \"unit\": \"sint culpa voluptate\",\n \"isString\": true,\n \"isStep\": true,\n \"metadata\": {},\n \"assetIds\": [\n 8392988761056162,\n 2911403766826494\n ],\n \"assetExternalIds\": [\n \"esse non aute\",\n \"dolor in amet et minim\"\n ],\n \"rootAssetIds\": [\n 4628243625090460,\n 3862854227867686\n ],\n \"assetSubtreeIds\": [\n {\n \"id\": 229005040467072\n },\n {\n \"externalId\": \"aute in elit aliquip\"\n }\n ],\n \"dataSetIds\": [\n {\n \"externalId\": \"voluptate adipisicing ex in dolore\"\n },\n {\n \"externalId\": \"irure laboris consectetur veniam velit\"\n }\n ],\n \"externalIdPrefix\": \"veniam\",\n \"createdTime\": {\n \"max\": 11556036,\n \"min\": 65169412\n },\n \"lastUpdatedTime\": {\n \"max\": 47360518,\n \"min\": 36601806\n }\n },\n \"search\": {\n \"name\": \"cupi\",\n \"description\": \"aliqua ut mi\",\n \"query\": \"in id fugiat\"\n },\n \"limit\": 100\n}"
}
}
}