Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Get long-running tasks

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
string ls_Key
integer li_ElapsedTime
integer li_PercentageComplete
integer li_Successful
integer j
integer li_Count_j
string ls_Translation
integer li_Start
integer li_Limit
integer li_Size
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_QueryParams.UpdateInt("start",0)
loo_QueryParams.UpdateInt("limit",100)

loo_Resp = loo_Http.QuickRequestParams("GET","https://your-domain.atlassian.net/wiki/rest/api/longtask",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// 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

li_Start = loo_JResp.IntOf("start")
li_Limit = loo_JResp.IntOf("limit")
li_Size = loo_JResp.IntOf("size")
i = 0
li_Count_i = loo_JResp.SizeOfArray("results")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Id = loo_JResp.StringOf("results[i].id")
    ls_Key = loo_JResp.StringOf("results[i].name.key")
    li_ElapsedTime = loo_JResp.IntOf("results[i].elapsedTime")
    li_PercentageComplete = loo_JResp.IntOf("results[i].percentageComplete")
    li_Successful = loo_JResp.BoolOf("results[i].successful")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("results[i].messages")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Translation = loo_JResp.StringOf("results[i].messages[j].translation")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

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": ""
    }
  ]
}