Chilkat Online Tools

DataFlex / Atlassian Confluence Cloud / Get watches for page

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vQueryParams
    Handle hoQueryParams
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sV_type
    String sV_Type
    String sPath
    Integer iWidth
    Integer iHeight
    Boolean iIsDefault
    String sDisplayName
    String sAccountId
    String sValue
    String sPersonalValue
    String sUsername
    String sUserKey
    String sContentId
    Integer j
    Integer iCount_j
    String sOperation
    String sTargetType
    Integer iStart
    Integer iLimit
    Integer iSize
    Integer i
    Integer iCount_i
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
    If (Not(IsComObjectCreated(hoQueryParams))) Begin
        Send CreateComObject of hoQueryParams
    End
    Get ComUpdateInt Of hoQueryParams "start" 0 To iSuccess
    Get ComUpdateInt Of hoQueryParams "limit" 200 To iSuccess

    // Adds the "Authorization: Bearer <access_token>" header.
    Set ComAuthToken Of hoHttp To "<access_token>"

    Get pvComObject of hoQueryParams to vQueryParams
    Get ComQuickRequestParams Of hoHttp "GET" "https://your-domain.atlassian.net/wiki/rest/api/content/:id/notification/child-created" vQueryParams To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

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

    Get ComIntOf Of hoJResp "start" To iStart
    Get ComIntOf Of hoJResp "limit" To iLimit
    Get ComIntOf Of hoJResp "size" To iSize
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "results" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "results[i].type" To sV_type
        Get ComStringOf Of hoJResp "results[i].watcher.type" To sV_Type
        Get ComStringOf Of hoJResp "results[i].watcher.profilePicture.path" To sPath
        Get ComIntOf Of hoJResp "results[i].watcher.profilePicture.width" To iWidth
        Get ComIntOf Of hoJResp "results[i].watcher.profilePicture.height" To iHeight
        Get ComBoolOf Of hoJResp "results[i].watcher.profilePicture.isDefault" To iIsDefault
        Get ComStringOf Of hoJResp "results[i].watcher.displayName" To sDisplayName
        Get ComStringOf Of hoJResp "results[i].watcher.accountId" To sAccountId
        Get ComStringOf Of hoJResp "results[i].watcher.details.business.value" To sValue
        Get ComStringOf Of hoJResp "results[i].watcher.details.personal.value" To sPersonalValue
        Get ComStringOf Of hoJResp "results[i].watcher.username" To sUsername
        Get ComStringOf Of hoJResp "results[i].watcher.userKey" To sUserKey
        Get ComStringOf Of hoJResp "results[i].contentId" To sContentId
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "results[i].watcher.operations" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "results[i].watcher.operations[j].operation" To sOperation
            Get ComStringOf Of hoJResp "results[i].watcher.operations[j].targetType" To sTargetType
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

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