Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Get space watchers

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_V_type
string ls_V_Type
string ls_Path
integer li_Width
integer li_Height
integer li_IsDefault
string ls_DisplayName
string ls_AccountId
string ls_AccountType
string ls_V_Email
string ls_PublicName
string ls_Username
string ls_UserKey
string ls_Value
string ls_PersonalValue
string ls_SpaceKey
string ls_ContentId
integer j
integer li_Count_j
string ls_Operation
string ls_TargetType
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
// 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

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

loo_QueryParams.UpdateString("start","<string>")
loo_QueryParams.UpdateString("limit","<string>")

loo_Resp = loo_Http.QuickRequestParams("GET","https://your-domain.atlassian.net/wiki/rest/api/space/:spaceKey/watch",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
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.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": [
//     {
//       "type": "proident nisi dolo",
//       "watcher": {
//         "type": "veniam enim exercitation ",
//         "profilePicture": {
//           "path": "Duis velit",
//           "width": -59620755,
//           "height": 31433400,
//           "isDefault": true
//         },
//         "displayName": "reprehenderit dolor ea magna",
//         "accountId": "sint enim volupta",
//         "accountType": "do ea ipsum ullamco",
//         "email": "dolor",
//         "publicName": "do aliqua",
//         "username": "nisi officia",
//         "userKey": "sint a",
//         "operations": [
//           {
//             "operation": "move",
//             "targetType": "attachment"
//           },
//           {
//             "operation": "move",
//             "targetType": "attachment"
//           }
//         ],
//         "details": {
//           "business": {
//             "value": "<Error: Too many levels of nesting to fake this schema>"
//           },
//           "personal": {
//             "value": "<Error: Too many levels of nesting to fake this schema>"
//           }
//         }
//       },
//       "spaceKey": "minim ex",
//       "contentId": "do"
//     },
//     {
//       "type": "ut in Duis ad",
//       "watcher": {
//         "type": "dolor id",
//         "profilePicture": {
//           "path": "dolore Ut",
//           "width": -91859267,
//           "height": 76867520,
//           "isDefault": false
//         },
//         "displayName": "magna in veniam aliqua dolor",
//         "accountId": "ut incididunt",
//         "accountType": "sint Lorem",
//         "email": "voluptate id",
//         "publicName": "Duis mi",
//         "username": "dolor consectetur venia",
//         "userKey": "reprehenderit eius",
//         "operations": [
//           {
//             "operation": "administer",
//             "targetType": "page"
//           },
//           {
//             "operation": "purge_version",
//             "targetType": "comment"
//           }
//         ],
//         "details": {
//           "business": {
//             "value": "<Error: Too many levels of nesting to fake this schema>"
//           },
//           "personal": {
//             "value": "<Error: Too many levels of nesting to fake this schema>"
//           }
//         }
//       },
//       "spaceKey": "Duis minim",
//       "contentId": "est irure dolore"
//     }
//   ],
//   "start": 36796637,
//   "limit": -14900038,
//   "size": -90406538,
//   "_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_V_type = loo_JResp.StringOf("results[i].type")
    ls_V_Type = loo_JResp.StringOf("results[i].watcher.type")
    ls_Path = loo_JResp.StringOf("results[i].watcher.profilePicture.path")
    li_Width = loo_JResp.IntOf("results[i].watcher.profilePicture.width")
    li_Height = loo_JResp.IntOf("results[i].watcher.profilePicture.height")
    li_IsDefault = loo_JResp.BoolOf("results[i].watcher.profilePicture.isDefault")
    ls_DisplayName = loo_JResp.StringOf("results[i].watcher.displayName")
    ls_AccountId = loo_JResp.StringOf("results[i].watcher.accountId")
    ls_AccountType = loo_JResp.StringOf("results[i].watcher.accountType")
    ls_V_Email = loo_JResp.StringOf("results[i].watcher.email")
    ls_PublicName = loo_JResp.StringOf("results[i].watcher.publicName")
    ls_Username = loo_JResp.StringOf("results[i].watcher.username")
    ls_UserKey = loo_JResp.StringOf("results[i].watcher.userKey")
    ls_Value = loo_JResp.StringOf("results[i].watcher.details.business.value")
    ls_PersonalValue = loo_JResp.StringOf("results[i].watcher.details.personal.value")
    ls_SpaceKey = loo_JResp.StringOf("results[i].spaceKey")
    ls_ContentId = loo_JResp.StringOf("results[i].contentId")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("results[i].watcher.operations")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Operation = loo_JResp.StringOf("results[i].watcher.operations[j].operation")
        ls_TargetType = loo_JResp.StringOf("results[i].watcher.operations[j].targetType")
        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=%3Cstring%3E"
	-d "limit=%3Cstring%3E"
https://your-domain.atlassian.net/wiki/rest/api/space/:spaceKey/watch

Postman Collection Item JSON

{
  "name": "Get space watchers",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/space/:spaceKey/watch?start=<string>&limit=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "space",
        ":spaceKey",
        "watch"
      ],
      "query": [
        {
          "key": "start",
          "value": "<string>",
          "description": "The start point of the collection to return."
        },
        {
          "key": "limit",
          "value": "<string>",
          "description": "The limit of the number of items to return, this may be restricted by fixed system limits."
        }
      ],
      "variable": [
        {
          "key": "spaceKey",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The key of the space to get watchers."
        }
      ]
    },
    "description": "Returns a list of watchers of a space"
  },
  "response": [
    {
      "name": "Returned if watchers list is returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/space/:spaceKey/watch?start=<string>&limit=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "space",
            ":spaceKey",
            "watch"
          ],
          "query": [
            {
              "key": "start",
              "value": "<string>"
            },
            {
              "key": "limit",
              "value": "<string>"
            }
          ],
          "variable": [
            {
              "key": "spaceKey"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"results\": [\n  {\n   \"type\": \"proident nisi dolo\",\n   \"watcher\": {\n    \"type\": \"veniam enim exercitation \",\n    \"profilePicture\": {\n     \"path\": \"Duis velit\",\n     \"width\": -59620755,\n     \"height\": 31433400,\n     \"isDefault\": true\n    },\n    \"displayName\": \"reprehenderit dolor ea magna\",\n    \"accountId\": \"sint enim volupta\",\n    \"accountType\": \"do ea ipsum ullamco\",\n    \"email\": \"dolor\",\n    \"publicName\": \"do aliqua\",\n    \"username\": \"nisi officia\",\n    \"userKey\": \"sint a\",\n    \"operations\": [\n     {\n      \"operation\": \"move\",\n      \"targetType\": \"attachment\"\n     },\n     {\n      \"operation\": \"move\",\n      \"targetType\": \"attachment\"\n     }\n    ],\n    \"details\": {\n     \"business\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"personal\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    }\n   },\n   \"spaceKey\": \"minim ex\",\n   \"contentId\": \"do\"\n  },\n  {\n   \"type\": \"ut in Duis ad\",\n   \"watcher\": {\n    \"type\": \"dolor id\",\n    \"profilePicture\": {\n     \"path\": \"dolore Ut\",\n     \"width\": -91859267,\n     \"height\": 76867520,\n     \"isDefault\": false\n    },\n    \"displayName\": \"magna in veniam aliqua dolor\",\n    \"accountId\": \"ut incididunt\",\n    \"accountType\": \"sint Lorem\",\n    \"email\": \"voluptate id\",\n    \"publicName\": \"Duis mi\",\n    \"username\": \"dolor consectetur venia\",\n    \"userKey\": \"reprehenderit eius\",\n    \"operations\": [\n     {\n      \"operation\": \"administer\",\n      \"targetType\": \"page\"\n     },\n     {\n      \"operation\": \"purge_version\",\n      \"targetType\": \"comment\"\n     }\n    ],\n    \"details\": {\n     \"business\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     },\n     \"personal\": {\n      \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n     }\n    }\n   },\n   \"spaceKey\": \"Duis minim\",\n   \"contentId\": \"est irure dolore\"\n  }\n ],\n \"start\": 36796637,\n \"limit\": -14900038,\n \"size\": -90406538,\n \"_links\": {}\n}"
    },
    {
      "name": "Returned if there is no space with the given key",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/space/:spaceKey/watch?start=<string>&limit=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "space",
            ":spaceKey",
            "watch"
          ],
          "query": [
            {
              "key": "start",
              "value": "<string>"
            },
            {
              "key": "limit",
              "value": "<string>"
            }
          ],
          "variable": [
            {
              "key": "spaceKey"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}