Chilkat Online Tools

Swift / CleverTap API / Partial API

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

    let queryParams = CkoJsonObject()
    queryParams.UpdateString("req_id", value: "{{reqid}}")

    http.SetRequestHeader("X-CleverTap-Passcode", value: "{{passcode}}")
    http.SetRequestHeader("X-CleverTap-Account-Id", value: "{{id}}")
    http.SetRequestHeader("Content-Type", value: "{{type}}")

    var resp: CkoHttpResponse? = http.QuickRequestParams("GET", url: "https://api.clevertap.com/1/counts/trends.json", json: queryParams)
    if http.LastMethodSuccess == false {
        print("\(http.LastErrorText)")
        return
    }

    print("\(resp!.StatusCode.intValue)")
    print("\(resp!.BodyStr)")
    resp = nil

}

Curl Command

curl -G -d "req_id=%7B%7Breqid%7D%7D"
	-H "X-CleverTap-Account-Id: {{id}}"
	-H "X-CleverTap-Passcode: {{passcode}}"
	-H "Content-Type: {{type}}"
https://api.clevertap.com/1/counts/trends.json

Postman Collection Item JSON

{
  "name": "Partial API",
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "var result = JSON.parse(responseBody);",
          "pm.globals.set(\"req_id\",result.req_id);"
        ]
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "X-CleverTap-Account-Id",
        "value": "{{id}}"
      },
      {
        "key": "X-CleverTap-Passcode",
        "value": "{{passcode}}"
      },
      {
        "key": "Content-Type",
        "value": "{{type}}"
      }
    ],
    "url": {
      "raw": "https://api.clevertap.com/1/counts/trends.json?req_id={{reqid}}",
      "protocol": "https",
      "host": [
        "api",
        "clevertap",
        "com"
      ],
      "path": [
        "1",
        "counts",
        "trends.json"
      ],
      "query": [
        {
          "key": "req_id",
          "value": "{{reqid}}"
        }
      ]
    }
  },
  "response": [
  ]
}