Chilkat Online Tools

PowerBuilder / Cognite API v1 / Aggregate time series

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// 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": "et exercitation s",
//     "unit": "pariatur esse qui",
//     "isString": true,
//     "isStep": false,
//     "metadata": {},
//     "assetIds": [
//       2274246036570026,
//       8922483798410046
//     ],
//     "assetExternalIds": [
//       "proident Ut consequat in",
//       "elit incididunt aliqua"
//     ],
//     "rootAssetIds": [
//       7714215516056826,
//       4275780546438472
//     ],
//     "assetSubtreeIds": [
//       {
//         "id": 7555548287718054
//       },
//       {
//         "externalId": "re"
//       }
//     ],
//     "dataSetIds": [
//       {
//         "id": 5946532482497628
//       },
//       {
//         "externalId": "exercitation nisi elit"
//       }
//     ],
//     "externalIdPrefix": "aute Ut nostrud commodo in",
//     "createdTime": {
//       "max": 16041500,
//       "min": 71538919
//     },
//     "lastUpdatedTime": {
//       "max": 2438620,
//       "min": 18087967
//     }
//   }
// }

loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

loo_Json.UpdateString("filter.name","et exercitation s")
loo_Json.UpdateString("filter.unit","pariatur esse qui")
loo_Json.UpdateBool("filter.isString",1)
loo_Json.UpdateBool("filter.isStep",0)
loo_Json.UpdateNewObject("filter.metadata")
loo_Json.UpdateInt("filter.assetIds[0]",2274246036570026)
loo_Json.UpdateInt("filter.assetIds[1]",8922483798410046)
loo_Json.UpdateString("filter.assetExternalIds[0]","proident Ut consequat in")
loo_Json.UpdateString("filter.assetExternalIds[1]","elit incididunt aliqua")
loo_Json.UpdateInt("filter.rootAssetIds[0]",7714215516056826)
loo_Json.UpdateInt("filter.rootAssetIds[1]",4275780546438472)
loo_Json.UpdateInt("filter.assetSubtreeIds[0].id",123)
loo_Json.UpdateString("filter.assetSubtreeIds[1].externalId","re")
loo_Json.UpdateInt("filter.dataSetIds[0].id",123)
loo_Json.UpdateString("filter.dataSetIds[1].externalId","exercitation nisi elit")
loo_Json.UpdateString("filter.externalIdPrefix","aute Ut nostrud commodo in")
loo_Json.UpdateInt("filter.createdTime.max",16041500)
loo_Json.UpdateInt("filter.createdTime.min",71538919)
loo_Json.UpdateInt("filter.lastUpdatedTime.max",2438620)
loo_Json.UpdateInt("filter.lastUpdatedTime.min",18087967)

loo_Http.SetRequestHeader("content-type","application/json")
loo_Http.SetRequestHeader("api-key","{{api-key}}")

loo_Resp = loo_Http.PostJson3("https://domain.com/api/v1/projects/{{project}}/timeseries/aggregate","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_Json

Curl Command

curl -X POST
	-H "api-key: {{api-key}}"
	-H "content-type: application/json"
	-d '{
    "filter": {
        "name": "et exercitation s",
        "unit": "pariatur esse qui",
        "isString": true,
        "isStep": false,
        "metadata": {},
        "assetIds": [
            2274246036570026,
            8922483798410046
        ],
        "assetExternalIds": [
            "proident Ut consequat in",
            "elit incididunt aliqua"
        ],
        "rootAssetIds": [
            7714215516056826,
            4275780546438472
        ],
        "assetSubtreeIds": [
            {
                "id": 7555548287718054
            },
            {
                "externalId": "re"
            }
        ],
        "dataSetIds": [
            {
                "id": 5946532482497628
            },
            {
                "externalId": "exercitation nisi elit"
            }
        ],
        "externalIdPrefix": "aute Ut nostrud commodo in",
        "createdTime": {
            "max": 16041500,
            "min": 71538919
        },
        "lastUpdatedTime": {
            "max": 2438620,
            "min": 18087967
        }
    }
}'
https://domain.com/api/v1/projects/{{project}}/timeseries/aggregate

Postman Collection Item JSON

{
  "id": "aggregateTimeSeries",
  "name": "Aggregate time series",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "timeseries",
        "aggregate"
      ],
      "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": "Count the number of time series that match the given filter",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"name\": \"et exercitation s\",\n        \"unit\": \"pariatur esse qui\",\n        \"isString\": true,\n        \"isStep\": false,\n        \"metadata\": {},\n        \"assetIds\": [\n            2274246036570026,\n            8922483798410046\n        ],\n        \"assetExternalIds\": [\n            \"proident Ut consequat in\",\n            \"elit incididunt aliqua\"\n        ],\n        \"rootAssetIds\": [\n            7714215516056826,\n            4275780546438472\n        ],\n        \"assetSubtreeIds\": [\n            {\n                \"id\": 7555548287718054\n            },\n            {\n                \"externalId\": \"re\"\n            }\n        ],\n        \"dataSetIds\": [\n            {\n                \"id\": 5946532482497628\n            },\n            {\n                \"externalId\": \"exercitation nisi elit\"\n            }\n        ],\n        \"externalIdPrefix\": \"aute Ut nostrud commodo in\",\n        \"createdTime\": {\n            \"max\": 16041500,\n            \"min\": 71538919\n        },\n        \"lastUpdatedTime\": {\n            \"max\": 2438620,\n            \"min\": 18087967\n        }\n    }\n}"
    }
  }
}