Chilkat Online Tools

Swift3 / Cognite API v1 / Filter time series

Back to Collection Items

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!
    var success: Bool

    // 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": "consectetur reprehenderit",
    //     "unit": "voluptate occaecat ut dolor ",
    //     "isString": true,
    //     "isStep": false,
    //     "metadata": {},
    //     "assetIds": [
    //       2509118978120224,
    //       7226404981552392
    //     ],
    //     "assetExternalIds": [
    //       "est laborum",
    //       "in in et aliquip"
    //     ],
    //     "rootAssetIds": [
    //       6708483845679534,
    //       3834273847268414
    //     ],
    //     "assetSubtreeIds": [
    //       {
    //         "id": 4838322974326730
    //       },
    //       {
    //         "externalId": "nisi Excepteur exercitation nulla reprehenderit"
    //       }
    //     ],
    //     "dataSetIds": [
    //       {
    //         "externalId": "Ut ex consectetur"
    //       },
    //       {
    //         "id": 8956424920459844
    //       }
    //     ],
    //     "externalIdPrefix": "reprehenderit fugiat pariatur id culpa",
    //     "createdTime": {
    //       "max": 82460819,
    //       "min": 76400255
    //     },
    //     "lastUpdatedTime": {
    //       "max": 24839160,
    //       "min": 94565958
    //     }
    //   },
    //   "limit": 100,
    //   "cursor": "pariatur quis eu anim",
    //   "partition": "do amet consectetur ad f"
    // }

    let json = CkoJsonObject()!
    json.update("filter.name", value: "consectetur reprehenderit")
    json.update("filter.unit", value: "voluptate occaecat ut dolor ")
    json.updateBool("filter.isString", value: true)
    json.updateBool("filter.isStep", value: false)
    json.updateNewObject("filter.metadata")
    json.updateInt("filter.assetIds[0]", value: 2509118978120224)
    json.updateInt("filter.assetIds[1]", value: 7226404981552392)
    json.update("filter.assetExternalIds[0]", value: "est laborum")
    json.update("filter.assetExternalIds[1]", value: "in in et aliquip")
    json.updateInt("filter.rootAssetIds[0]", value: 6708483845679534)
    json.updateInt("filter.rootAssetIds[1]", value: 3834273847268414)
    json.updateInt("filter.assetSubtreeIds[0].id", value: 123)
    json.update("filter.assetSubtreeIds[1].externalId", value: "nisi Excepteur exercitation nulla reprehenderit")
    json.update("filter.dataSetIds[0].externalId", value: "Ut ex consectetur")
    json.updateInt("filter.dataSetIds[1].id", value: 123)
    json.update("filter.externalIdPrefix", value: "reprehenderit fugiat pariatur id culpa")
    json.updateInt("filter.createdTime.max", value: 82460819)
    json.updateInt("filter.createdTime.min", value: 76400255)
    json.updateInt("filter.lastUpdatedTime.max", value: 24839160)
    json.updateInt("filter.lastUpdatedTime.min", value: 94565958)
    json.updateInt("limit", value: 100)
    json.update("cursor", value: "pariatur quis eu anim")
    json.update("partition", value: "do amet consectetur ad f")

    http.setRequestHeader("content-type", value: "application/json")
    http.setRequestHeader("api-key", value: "{{api-key}}")

    var resp: CkoHttpResponse? = http.postJson3("https://domain.com/api/v1/projects/{{project}}/timeseries/list", contentType: "application/json", json: json)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("\(resp!.statusCode.intValue)")
    print("\(resp!.bodyStr!)")
    resp = nil

}

Curl Command

curl -X POST
	-H "api-key: {{api-key}}"
	-H "content-type: application/json"
	-d '{
    "filter": {
        "name": "consectetur reprehenderit",
        "unit": "voluptate occaecat ut dolor ",
        "isString": true,
        "isStep": false,
        "metadata": {},
        "assetIds": [
            2509118978120224,
            7226404981552392
        ],
        "assetExternalIds": [
            "est laborum",
            "in in et aliquip"
        ],
        "rootAssetIds": [
            6708483845679534,
            3834273847268414
        ],
        "assetSubtreeIds": [
            {
                "id": 4838322974326730
            },
            {
                "externalId": "nisi Excepteur exercitation nulla reprehenderit"
            }
        ],
        "dataSetIds": [
            {
                "externalId": "Ut ex consectetur"
            },
            {
                "id": 8956424920459844
            }
        ],
        "externalIdPrefix": "reprehenderit fugiat pariatur id culpa",
        "createdTime": {
            "max": 82460819,
            "min": 76400255
        },
        "lastUpdatedTime": {
            "max": 24839160,
            "min": 94565958
        }
    },
    "limit": 100,
    "cursor": "pariatur quis eu anim",
    "partition": "do amet consectetur ad f"
}'
https://domain.com/api/v1/projects/{{project}}/timeseries/list

Postman Collection Item JSON

{
  "id": "listTimeSeries",
  "name": "Filter time series",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "timeseries",
        "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 time series matching the specified criteria. This operation supports pagination by cursor. Criteria can be applied to select a subset of time series.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"name\": \"consectetur reprehenderit\",\n        \"unit\": \"voluptate occaecat ut dolor \",\n        \"isString\": true,\n        \"isStep\": false,\n        \"metadata\": {},\n        \"assetIds\": [\n            2509118978120224,\n            7226404981552392\n        ],\n        \"assetExternalIds\": [\n            \"est laborum\",\n            \"in in et aliquip\"\n        ],\n        \"rootAssetIds\": [\n            6708483845679534,\n            3834273847268414\n        ],\n        \"assetSubtreeIds\": [\n            {\n                \"id\": 4838322974326730\n            },\n            {\n                \"externalId\": \"nisi Excepteur exercitation nulla reprehenderit\"\n            }\n        ],\n        \"dataSetIds\": [\n            {\n                \"externalId\": \"Ut ex consectetur\"\n            },\n            {\n                \"id\": 8956424920459844\n            }\n        ],\n        \"externalIdPrefix\": \"reprehenderit fugiat pariatur id culpa\",\n        \"createdTime\": {\n            \"max\": 82460819,\n            \"min\": 76400255\n        },\n        \"lastUpdatedTime\": {\n            \"max\": 24839160,\n            \"min\": 94565958\n        }\n    },\n    \"limit\": 100,\n    \"cursor\": \"pariatur quis eu anim\",\n    \"partition\": \"do amet consectetur ad f\"\n}"
    }
  }
}