Chilkat Online Tools

DataFlex / Cognite API v1 / Search time series

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

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "filter.name" "dolor eiusmod nostrud ea cillum" To iSuccess
    Get ComUpdateString Of hoJson "filter.unit" "sint culpa voluptate" To iSuccess
    Get ComUpdateBool Of hoJson "filter.isString" True To iSuccess
    Get ComUpdateBool Of hoJson "filter.isStep" True To iSuccess
    Get ComUpdateNewObject Of hoJson "filter.metadata" To iSuccess
    Get ComUpdateInt Of hoJson "filter.assetIds[0]" 8392988761056162 To iSuccess
    Get ComUpdateInt Of hoJson "filter.assetIds[1]" 2911403766826494 To iSuccess
    Get ComUpdateString Of hoJson "filter.assetExternalIds[0]" "esse non aute" To iSuccess
    Get ComUpdateString Of hoJson "filter.assetExternalIds[1]" "dolor in amet et minim" To iSuccess
    Get ComUpdateInt Of hoJson "filter.rootAssetIds[0]" 4628243625090460 To iSuccess
    Get ComUpdateInt Of hoJson "filter.rootAssetIds[1]" 3862854227867686 To iSuccess
    Get ComUpdateInt Of hoJson "filter.assetSubtreeIds[0].id" 123 To iSuccess
    Get ComUpdateString Of hoJson "filter.assetSubtreeIds[1].externalId" "aute in elit aliquip" To iSuccess
    Get ComUpdateString Of hoJson "filter.dataSetIds[0].externalId" "voluptate adipisicing ex in dolore" To iSuccess
    Get ComUpdateString Of hoJson "filter.dataSetIds[1].externalId" "irure laboris consectetur veniam velit" To iSuccess
    Get ComUpdateString Of hoJson "filter.externalIdPrefix" "veniam" To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.max" 11556036 To iSuccess
    Get ComUpdateInt Of hoJson "filter.createdTime.min" 65169412 To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.max" 47360518 To iSuccess
    Get ComUpdateInt Of hoJson "filter.lastUpdatedTime.min" 36601806 To iSuccess
    Get ComUpdateString Of hoJson "search.name" "cupi" To iSuccess
    Get ComUpdateString Of hoJson "search.description" "aliqua ut mi" To iSuccess
    Get ComUpdateString Of hoJson "search.query" "in id fugiat" To iSuccess
    Get ComUpdateInt Of hoJson "limit" 100 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}}/timeseries/search" "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": {
        "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}"
    }
  }
}