Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Get watches for page

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_Value
string ls_PersonalValue
string ls_Username
string ls_UserKey
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
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",200)

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_Resp = loo_Http.QuickRequestParams("GET","https://your-domain.atlassian.net/wiki/rest/api/content/:id/notification/child-created",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": [
//     {
//       "type": "Dui",
//       "watcher": {
//         "type": "voluptate",
//         "profilePicture": {
//           "path": "cillum",
//           "width": 28975792,
//           "height": -2569548,
//           "isDefault": true
//         },
//         "displayName": "aliqua",
//         "operations": [
//           {
//             "operation": "export",
//             "targetType": "space"
//           },
//           {
//             "operation": "administer",
//             "targetType": "blogpost"
//           }
//         ],
//         "accountId": "ex reprehenderit in",
//         "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>"
//           }
//         },
//         "username": "ex nisi nulla nostrud adipisicing",
//         "userKey": "esse sunt dolore"
//       },
//       "contentId": "ut aute voluptate"
//     },
//     {
//       "type": "dolore dolor",
//       "watcher": {
//         "type": "qui ea cillum mollit",
//         "profilePicture": {
//           "path": "esse dolor veniam",
//           "width": 73225956,
//           "height": 11139116,
//           "isDefault": false
//         },
//         "displayName": "aliquip ex",
//         "operations": [
//           {
//             "operation": "read",
//             "targetType": "attachment"
//           },
//           {
//             "operation": "delete",
//             "targetType": "attachment"
//           }
//         ],
//         "accountId": "sed nu",
//         "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>"
//           }
//         },
//         "username": "cupidatat amet adipisicing Excepteur",
//         "userKey": "dolore eiusmod id adipisicing"
//       },
//       "contentId": "incididunt non in irure proident"
//     }
//   ],
//   "start": 28460425,
//   "limit": -13406271,
//   "size": 94884215,
//   "_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_Value = loo_JResp.StringOf("results[i].watcher.details.business.value")
    ls_PersonalValue = loo_JResp.StringOf("results[i].watcher.details.personal.value")
    ls_Username = loo_JResp.StringOf("results[i].watcher.username")
    ls_UserKey = loo_JResp.StringOf("results[i].watcher.userKey")
    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=0"
	-d "limit=200"
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/content/:id/notification/child-created

Postman Collection Item JSON

{
  "name": "Get watches for page",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/content/:id/notification/child-created?start=0&limit=200",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "content",
        ":id",
        "notification",
        "child-created"
      ],
      "query": [
        {
          "key": "start",
          "value": "0",
          "description": "The starting index of the returned watches."
        },
        {
          "key": "limit",
          "value": "200",
          "description": "The maximum number of watches to return per page.\nNote, this may be restricted by fixed system limits."
        }
      ],
      "variable": [
        {
          "key": "id",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The ID of the content to be queried for its watches."
        }
      ]
    },
    "description": "Returns the watches for a page. A user that watches a page will receive\nreceive notifications when the page is updated.\n\nIf you want to manage watches for a page, use the following `user` methods:\n\n- [Get content watch status for user](#api-user-watch-content-contentId-get)\n- [Add content watch](#api-user-watch-content-contentId-post)\n- [Remove content watch](#api-user-watch-content-contentId-delete)\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 watches are returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/content/:id/notification/child-created?start=0&limit=200",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "content",
            ":id",
            "notification",
            "child-created"
          ],
          "query": [
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "200"
            }
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"results\": [\n  {\n   \"type\": \"Dui\",\n   \"watcher\": {\n    \"type\": \"voluptate\",\n    \"profilePicture\": {\n     \"path\": \"cillum\",\n     \"width\": 28975792,\n     \"height\": -2569548,\n     \"isDefault\": true\n    },\n    \"displayName\": \"aliqua\",\n    \"operations\": [\n     {\n      \"operation\": \"export\",\n      \"targetType\": \"space\"\n     },\n     {\n      \"operation\": \"administer\",\n      \"targetType\": \"blogpost\"\n     }\n    ],\n    \"accountId\": \"ex reprehenderit in\",\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    \"username\": \"ex nisi nulla nostrud adipisicing\",\n    \"userKey\": \"esse sunt dolore\"\n   },\n   \"contentId\": \"ut aute voluptate\"\n  },\n  {\n   \"type\": \"dolore dolor\",\n   \"watcher\": {\n    \"type\": \"qui ea cillum mollit\",\n    \"profilePicture\": {\n     \"path\": \"esse dolor veniam\",\n     \"width\": 73225956,\n     \"height\": 11139116,\n     \"isDefault\": false\n    },\n    \"displayName\": \"aliquip ex\",\n    \"operations\": [\n     {\n      \"operation\": \"read\",\n      \"targetType\": \"attachment\"\n     },\n     {\n      \"operation\": \"delete\",\n      \"targetType\": \"attachment\"\n     }\n    ],\n    \"accountId\": \"sed nu\",\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    \"username\": \"cupidatat amet adipisicing Excepteur\",\n    \"userKey\": \"dolore eiusmod id adipisicing\"\n   },\n   \"contentId\": \"incididunt non in irure proident\"\n  }\n ],\n \"start\": 28460425,\n \"limit\": -13406271,\n \"size\": 94884215,\n \"_links\": {}\n}"
    },
    {
      "name": "Returned if the authentication credentials are incorrect or missing\nfrom the request.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/content/:id/notification/child-created?start=0&limit=200",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "content",
            ":id",
            "notification",
            "child-created"
          ],
          "query": [
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "200"
            }
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}