SQL Server / Cognite API v1 / Filter relationships
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": {
-- "sourceExternalIds": [
-- "culpa esse veniam nisi",
-- "commodo repr"
-- ],
-- "sourceTypes": [
-- "timeSeries",
-- "sequence"
-- ],
-- "targetExternalIds": [
-- "exercitation",
-- "enim culpa"
-- ],
-- "targetTypes": [
-- "sequence",
-- "timeSeries"
-- ],
-- "dataSetIds": [
-- {
-- "id": 6853944784929184
-- },
-- {
-- "externalId": "aliquip non"
-- }
-- ],
-- "startTime": {
-- "max": 15446345,
-- "min": 52529591
-- },
-- "endTime": {
-- "max": 94684273,
-- "min": 31959617
-- },
-- "confidence": {
-- "min": 62943472.11126715,
-- "max": 33071678.92549883
-- },
-- "lastUpdatedTime": {
-- "max": 64148230,
-- "min": 15602664
-- },
-- "createdTime": {
-- "max": 99622074,
-- "min": 32696551
-- },
-- "activeAtTime": {
-- "max": 99890540,
-- "min": 14084932
-- },
-- "labels": {
-- "containsAny": [
-- {
-- "externalId": "et Lorem cupidatat amet"
-- },
-- {
-- "externalId": "aliqua"
-- }
-- ]
-- },
-- "sourcesOrTargets": [
-- {
-- "type": "sequence",
-- "externalId": "consequat id"
-- }
-- ]
-- },
-- "limit": 100,
-- "cursor": "non do Excepteur dolor",
-- "fetchResources": false,
-- "partition": "laborum id ad cupidatat et"
-- }
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.sourceExternalIds[0]', 'culpa esse veniam nisi'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.sourceExternalIds[1]', 'commodo repr'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.sourceTypes[0]', 'timeSeries'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.sourceTypes[1]', 'sequence'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.targetExternalIds[0]', 'exercitation'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.targetExternalIds[1]', 'enim culpa'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.targetTypes[0]', 'sequence'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.targetTypes[1]', 'timeSeries'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.dataSetIds[0].id', 123
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.dataSetIds[1].externalId', 'aliquip non'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.startTime.max', 15446345
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.startTime.min', 52529591
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.endTime.max', 94684273
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.endTime.min', 31959617
EXEC sp_OAMethod @json, 'UpdateNumber', @success OUT, 'filter.confidence.min', '62943472.11126715'
EXEC sp_OAMethod @json, 'UpdateNumber', @success OUT, 'filter.confidence.max', '33071678.92549883'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.max', 64148230
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.lastUpdatedTime.min', 15602664
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.max', 99622074
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.createdTime.min', 32696551
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.activeAtTime.max', 99890540
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'filter.activeAtTime.min', 14084932
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.labels.containsAny[0].externalId', 'et Lorem cupidatat amet'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.labels.containsAny[1].externalId', 'aliqua'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.sourcesOrTargets[0].type', 'sequence'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'filter.sourcesOrTargets[0].externalId', 'consequat id'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'limit', 100
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'cursor', 'non do Excepteur dolor'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'fetchResources', 0
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'partition', 'laborum id ad cupidatat et'
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}}/relationships/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": {
"sourceExternalIds": [
"culpa esse veniam nisi",
"commodo repr"
],
"sourceTypes": [
"timeSeries",
"sequence"
],
"targetExternalIds": [
"exercitation",
"enim culpa"
],
"targetTypes": [
"sequence",
"timeSeries"
],
"dataSetIds": [
{
"id": 6853944784929184
},
{
"externalId": "aliquip non"
}
],
"startTime": {
"max": 15446345,
"min": 52529591
},
"endTime": {
"max": 94684273,
"min": 31959617
},
"confidence": {
"min": 62943472.11126715,
"max": 33071678.92549883
},
"lastUpdatedTime": {
"max": 64148230,
"min": 15602664
},
"createdTime": {
"max": 99622074,
"min": 32696551
},
"activeAtTime": {
"max": 99890540,
"min": 14084932
},
"labels": {
"containsAny": [
{
"externalId": "et Lorem cupidatat amet"
},
{
"externalId": "aliqua"
}
]
},
"sourcesOrTargets": [
{
"type": "sequence",
"externalId": "consequat id"
}
]
},
"limit": 100,
"cursor": "non do Excepteur dolor",
"fetchResources": false,
"partition": "laborum id ad cupidatat et"
}'
https://domain.com/api/v1/projects/{{project}}/relationships/list
Postman Collection Item JSON
{
"id": "listRelationships",
"name": "Filter relationships",
"request": {
"url": {
"host": "{{baseUrl}}",
"path": [
"api",
"v1",
"projects",
"{{project}}",
"relationships",
"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": "Lists relationships matching the query filter in the request. You can retrieve a maximum of 1000 relationships per request.",
"body": {
"mode": "raw",
"raw": "{\n \"filter\": {\n \"sourceExternalIds\": [\n \"culpa esse veniam nisi\",\n \"commodo repr\"\n ],\n \"sourceTypes\": [\n \"timeSeries\",\n \"sequence\"\n ],\n \"targetExternalIds\": [\n \"exercitation\",\n \"enim culpa\"\n ],\n \"targetTypes\": [\n \"sequence\",\n \"timeSeries\"\n ],\n \"dataSetIds\": [\n {\n \"id\": 6853944784929184\n },\n {\n \"externalId\": \"aliquip non\"\n }\n ],\n \"startTime\": {\n \"max\": 15446345,\n \"min\": 52529591\n },\n \"endTime\": {\n \"max\": 94684273,\n \"min\": 31959617\n },\n \"confidence\": {\n \"min\": 62943472.11126715,\n \"max\": 33071678.92549883\n },\n \"lastUpdatedTime\": {\n \"max\": 64148230,\n \"min\": 15602664\n },\n \"createdTime\": {\n \"max\": 99622074,\n \"min\": 32696551\n },\n \"activeAtTime\": {\n \"max\": 99890540,\n \"min\": 14084932\n },\n \"labels\": {\n \"containsAny\": [\n {\n \"externalId\": \"et Lorem cupidatat amet\"\n },\n {\n \"externalId\": \"aliqua\"\n }\n ]\n },\n \"sourcesOrTargets\": [\n {\n \"type\": \"sequence\",\n \"externalId\": \"consequat id\"\n }\n ]\n },\n \"limit\": 100,\n \"cursor\": \"non do Excepteur dolor\",\n \"fetchResources\": false,\n \"partition\": \"laborum id ad cupidatat et\"\n}"
}
}
}