Chilkat Online Tools

DataFlex / Cognite API v1 / Filter relationships

Back to Collection Items

Use ChilkatAx-9.5.0-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": {
    //     "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"
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "filter.sourceExternalIds[0]" "culpa esse veniam nisi" To iSuccess
    Get ComUpdateString Of hoJson "filter.sourceExternalIds[1]" "commodo repr" To iSuccess
    Get ComUpdateString Of hoJson "filter.sourceTypes[0]" "timeSeries" To iSuccess
    Get ComUpdateString Of hoJson "filter.sourceTypes[1]" "sequence" To iSuccess
    Get ComUpdateString Of hoJson "filter.targetExternalIds[0]" "exercitation" To iSuccess
    Get ComUpdateString Of hoJson "filter.targetExternalIds[1]" "enim culpa" To iSuccess
    Get ComUpdateString Of hoJson "filter.targetTypes[0]" "sequence" To iSuccess
    Get ComUpdateString Of hoJson "filter.targetTypes[1]" "timeSeries" To iSuccess
    Get ComUpdateInt Of hoJson "filter.dataSetIds[0].id" 123 To iSuccess
    Get ComUpdateString Of hoJson "filter.dataSetIds[1].externalId" "aliquip non" To iSuccess
    Get ComUpdateInt Of hoJson "filter.startTime.max" 15446345 To iSuccess
    Get ComUpdateInt Of hoJson "filter.startTime.min" 52529591 To iSuccess
    Get ComUpdateInt Of hoJson "filter.endTime.max" 94684273 To iSuccess
    Get ComUpdateInt Of hoJson "filter.endTime.min" 31959617 To iSuccess
    Get ComUpdateNumber Of hoJson "filter.confidence.min" "62943472.11126715" To iSuccess
    Get ComUpdateNumber Of hoJson "filter.confidence.max" "33071678.92549883" To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.max" 64148230 To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.min" 15602664 To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.max" 99622074 To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.min" 32696551 To iSuccess
    Get ComUpdateInt Of hoJson "filter.activeAtTime.max" 99890540 To iSuccess
    Get ComUpdateInt Of hoJson "filter.activeAtTime.min" 14084932 To iSuccess
    Get ComUpdateString Of hoJson "filter.labels.containsAny[0].externalId" "et Lorem cupidatat amet" To iSuccess
    Get ComUpdateString Of hoJson "filter.labels.containsAny[1].externalId" "aliqua" To iSuccess
    Get ComUpdateString Of hoJson "filter.sourcesOrTargets[0].type" "sequence" To iSuccess
    Get ComUpdateString Of hoJson "filter.sourcesOrTargets[0].externalId" "consequat id" To iSuccess
    Get ComUpdateInt Of hoJson "limit" 100 To iSuccess
    Get ComUpdateString Of hoJson "cursor" "non do Excepteur dolor" To iSuccess
    Get ComUpdateBool Of hoJson "fetchResources" False To iSuccess
    Get ComUpdateString Of hoJson "partition" "laborum id ad cupidatat et" 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}}/relationships/list" "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": {
        "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}"
    }
  }
}