Chilkat Online Tools

Swift3 / Cognite API v1 / Search sequences

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": "commodo non nulla aute",
    //     "externalIdPrefix": "commodo qui cupidatat",
    //     "metadata": {},
    //     "assetIds": [
    //       4769293985777598,
    //       5785768360784284
    //     ],
    //     "rootAssetIds": [
    //       1096264439313816,
    //       4922424346728832
    //     ],
    //     "assetSubtreeIds": [
    //       {
    //         "externalId": "exercitation pariatur id in"
    //       },
    //       {
    //         "id": 22443661565144
    //       }
    //     ],
    //     "createdTime": {
    //       "max": 14384577,
    //       "min": 60974975
    //     },
    //     "lastUpdatedTime": {
    //       "max": 83207483,
    //       "min": 43920599
    //     },
    //     "dataSetIds": [
    //       {
    //         "externalId": "voluptate e"
    //       },
    //       {
    //         "externalId": "laboris"
    //       }
    //     ]
    //   },
    //   "search": {
    //     "name": "non culpa irure velit consequat",
    //     "description": "id eiusmod",
    //     "query": "ad"
    //   },
    //   "limit": 100
    // }

    let json = CkoJsonObject()!
    json.update("filter.name", value: "commodo non nulla aute")
    json.update("filter.externalIdPrefix", value: "commodo qui cupidatat")
    json.updateNewObject("filter.metadata")
    json.updateInt("filter.assetIds[0]", value: 4769293985777598)
    json.updateInt("filter.assetIds[1]", value: 5785768360784284)
    json.updateInt("filter.rootAssetIds[0]", value: 1096264439313816)
    json.updateInt("filter.rootAssetIds[1]", value: 4922424346728832)
    json.update("filter.assetSubtreeIds[0].externalId", value: "exercitation pariatur id in")
    json.updateInt("filter.assetSubtreeIds[1].id", value: 123)
    json.updateInt("filter.createdTime.max", value: 14384577)
    json.updateInt("filter.createdTime.min", value: 60974975)
    json.updateInt("filter.lastUpdatedTime.max", value: 83207483)
    json.updateInt("filter.lastUpdatedTime.min", value: 43920599)
    json.update("filter.dataSetIds[0].externalId", value: "voluptate e")
    json.update("filter.dataSetIds[1].externalId", value: "laboris")
    json.update("search.name", value: "non culpa irure velit consequat")
    json.update("search.description", value: "id eiusmod")
    json.update("search.query", value: "ad")
    json.updateInt("limit", value: 100)

    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}}/sequences/search", 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": "commodo non nulla aute",
        "externalIdPrefix": "commodo qui cupidatat",
        "metadata": {},
        "assetIds": [
            4769293985777598,
            5785768360784284
        ],
        "rootAssetIds": [
            1096264439313816,
            4922424346728832
        ],
        "assetSubtreeIds": [
            {
                "externalId": "exercitation pariatur id in"
            },
            {
                "id": 22443661565144
            }
        ],
        "createdTime": {
            "max": 14384577,
            "min": 60974975
        },
        "lastUpdatedTime": {
            "max": 83207483,
            "min": 43920599
        },
        "dataSetIds": [
            {
                "externalId": "voluptate e"
            },
            {
                "externalId": "laboris"
            }
        ]
    },
    "search": {
        "name": "non culpa irure velit consequat",
        "description": "id eiusmod",
        "query": "ad"
    },
    "limit": 100
}'
https://domain.com/api/v1/projects/{{project}}/sequences/search

Postman Collection Item JSON

{
  "id": "searchSequences",
  "name": "Search sequences",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "sequences",
        "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": "Retrieves a list of sequences matching the given criteria. This operation does not support pagination.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"name\": \"commodo non nulla aute\",\n        \"externalIdPrefix\": \"commodo qui cupidatat\",\n        \"metadata\": {},\n        \"assetIds\": [\n            4769293985777598,\n            5785768360784284\n        ],\n        \"rootAssetIds\": [\n            1096264439313816,\n            4922424346728832\n        ],\n        \"assetSubtreeIds\": [\n            {\n                \"externalId\": \"exercitation pariatur id in\"\n            },\n            {\n                \"id\": 22443661565144\n            }\n        ],\n        \"createdTime\": {\n            \"max\": 14384577,\n            \"min\": 60974975\n        },\n        \"lastUpdatedTime\": {\n            \"max\": 83207483,\n            \"min\": 43920599\n        },\n        \"dataSetIds\": [\n            {\n                \"externalId\": \"voluptate e\"\n            },\n            {\n                \"externalId\": \"laboris\"\n            }\n        ]\n    },\n    \"search\": {\n        \"name\": \"non culpa irure velit consequat\",\n        \"description\": \"id eiusmod\",\n        \"query\": \"ad\"\n    },\n    \"limit\": 100\n}"
    }
  }
}