Chilkat Online Tools

DataFlex / Atlassian Confluence Cloud / Get space watchers

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 sAccountType
    String sV_Email
    String sPublicName
    String sUsername
    String sUserKey
    String sValue
    String sPersonalValue
    String sSpaceKey
    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 ComUpdateString Of hoQueryParams "start" "<string>" To iSuccess
    Get ComUpdateString Of hoQueryParams "limit" "<string>" To iSuccess

    Get pvComObject of hoQueryParams to vQueryParams
    Get ComQuickRequestParams Of hoHttp "GET" "https://your-domain.atlassian.net/wiki/rest/api/space/:spaceKey/watch" 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": "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

    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.accountType" To sAccountType
        Get ComStringOf Of hoJResp "results[i].watcher.email" To sV_Email
        Get ComStringOf Of hoJResp "results[i].watcher.publicName" To sPublicName
        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].watcher.details.business.value" To sValue
        Get ComStringOf Of hoJResp "results[i].watcher.details.personal.value" To sPersonalValue
        Get ComStringOf Of hoJResp "results[i].spaceKey" To sSpaceKey
        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=%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": ""
    }
  ]
}