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.updateInt("start", value: 0)
queryParams.updateInt("limit", value: 100)
var resp: CkoHttpResponse? = http.quickRequestParams("GET", url: "https://your-domain.atlassian.net/wiki/rest/api/longtask", json: queryParams)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
let sbResponseBody = CkoStringBuilder()!
resp!.getBodySb(sbResponseBody)
let jResp = CkoJsonObject()!
jResp.loadSb(sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = resp!.statusCode.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(resp!.header!)")
print("Failed.")
resp = nil
return
}
resp = nil
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "results": [
// {
// "id": "irure laborum reprehenderit",
// "name": {
// "key": "ea fugiat"
// },
// "elapsedTime": -80970955,
// "percentageComplete": -50700695,
// "successful": false,
// "messages": [
// {
// "translation": "laboris dolore est pariatur"
// },
// {
// "translation": "ut consectetur"
// }
// ]
// },
// {
// "id": "exercitation quis occaecat pariatur",
// "name": {
// "key": "ipsum enim consectetur laborum ea"
// },
// "elapsedTime": 68022774,
// "percentageComplete": -46095628,
// "successful": true,
// "messages": [
// {
// "translation": "ullamco officia Lorem occaecat"
// },
// {
// "translation": "aliquip de"
// }
// ]
// }
// ],
// "start": 73270285,
// "limit": -69580683,
// "size": 69587096,
// "_links": {}
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var id: String?
var Key: String?
var elapsedTime: Int
var percentageComplete: Int
var successful: Bool
var j: Int
var count_j: Int
var translation: String?
var start: Int = jResp.int(of: "start").intValue
var limit: Int = jResp.int(of: "limit").intValue
var size: Int = jResp.int(of: "size").intValue
var i: Int = 0
var count_i: Int = jResp.size(ofArray: "results").intValue
while i < count_i {
jResp.i = i
id = jResp.string(of: "results[i].id")
Key = jResp.string(of: "results[i].name.key")
elapsedTime = jResp.int(of: "results[i].elapsedTime").intValue
percentageComplete = jResp.int(of: "results[i].percentageComplete").intValue
successful = jResp.bool(of: "results[i].successful")
j = 0
count_j = jResp.size(ofArray: "results[i].messages").intValue
while j < count_j {
jResp.j = j
translation = jResp.string(of: "results[i].messages[j].translation")
j = j + 1
}
i = i + 1
}
}
Curl Command
curl -G -d "start=0"
-d "limit=100"
https://your-domain.atlassian.net/wiki/rest/api/longtask
Postman Collection Item JSON
{
"name": "Get long-running tasks",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/longtask?start=0&limit=100",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"longtask"
],
"query": [
{
"key": "start",
"value": "0",
"description": "The starting index of the returned tasks."
},
{
"key": "limit",
"value": "100",
"description": "The maximum number of tasks to return per page. Note, this may be\nrestricted by fixed system limits."
}
]
},
"description": "Returns information about all active long-running tasks (e.g. space export),\nsuch as how long each task has been running and the percentage of each task\nthat has completed.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to access the Confluence site ('Can use' global permission)."
},
"response": [
{
"name": "Returned if the requested tasks are returned.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/longtask?start=0&limit=100",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"longtask"
],
"query": [
{
"key": "start",
"value": "0"
},
{
"key": "limit",
"value": "100"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"results\": [\n {\n \"id\": \"irure laborum reprehenderit\",\n \"name\": {\n \"key\": \"ea fugiat\"\n },\n \"elapsedTime\": -80970955,\n \"percentageComplete\": -50700695,\n \"successful\": false,\n \"messages\": [\n {\n \"translation\": \"laboris dolore est pariatur\"\n },\n {\n \"translation\": \"ut consectetur\"\n }\n ]\n },\n {\n \"id\": \"exercitation quis occaecat pariatur\",\n \"name\": {\n \"key\": \"ipsum enim consectetur laborum ea\"\n },\n \"elapsedTime\": 68022774,\n \"percentageComplete\": -46095628,\n \"successful\": true,\n \"messages\": [\n {\n \"translation\": \"ullamco officia Lorem occaecat\"\n },\n {\n \"translation\": \"aliquip de\"\n }\n ]\n }\n ],\n \"start\": 73270285,\n \"limit\": -69580683,\n \"size\": 69587096,\n \"_links\": {}\n}"
},
{
"name": "Returned if the calling user is not logged in to Confluence.",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/longtask?start=0&limit=100",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"longtask"
],
"query": [
{
"key": "start",
"value": "0"
},
{
"key": "limit",
"value": "100"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}