Chilkat Online Tools

SQL Server / Atlassian Confluence Cloud / Get space watchers

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    DECLARE @queryParams int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @queryParams OUT

    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'start', '<string>'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'limit', '<string>'

    DECLARE @resp int
    EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://your-domain.atlassian.net/wiki/rest/api/space/:spaceKey/watch', @queryParams
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        RETURN
      END

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @resp

        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @queryParams
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END
    EXEC @hr = sp_OADestroy @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

    DECLARE @v_type nvarchar(4000)

    DECLARE @v_Type nvarchar(4000)

    DECLARE @Path nvarchar(4000)

    DECLARE @Width int

    DECLARE @Height int

    DECLARE @IsDefault int

    DECLARE @DisplayName nvarchar(4000)

    DECLARE @AccountId nvarchar(4000)

    DECLARE @AccountType nvarchar(4000)

    DECLARE @v_Email nvarchar(4000)

    DECLARE @PublicName nvarchar(4000)

    DECLARE @Username nvarchar(4000)

    DECLARE @UserKey nvarchar(4000)

    DECLARE @Value nvarchar(4000)

    DECLARE @PersonalValue nvarchar(4000)

    DECLARE @spaceKey nvarchar(4000)

    DECLARE @contentId nvarchar(4000)

    DECLARE @j int

    DECLARE @count_j int

    DECLARE @operation nvarchar(4000)

    DECLARE @targetType nvarchar(4000)

    DECLARE @start int
    EXEC sp_OAMethod @jResp, 'IntOf', @start OUT, 'start'
    DECLARE @limit int
    EXEC sp_OAMethod @jResp, 'IntOf', @limit OUT, 'limit'
    DECLARE @size int
    EXEC sp_OAMethod @jResp, 'IntOf', @size OUT, 'size'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'results'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @v_type OUT, 'results[i].type'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'results[i].watcher.type'
        EXEC sp_OAMethod @jResp, 'StringOf', @Path OUT, 'results[i].watcher.profilePicture.path'
        EXEC sp_OAMethod @jResp, 'IntOf', @Width OUT, 'results[i].watcher.profilePicture.width'
        EXEC sp_OAMethod @jResp, 'IntOf', @Height OUT, 'results[i].watcher.profilePicture.height'
        EXEC sp_OAMethod @jResp, 'BoolOf', @IsDefault OUT, 'results[i].watcher.profilePicture.isDefault'
        EXEC sp_OAMethod @jResp, 'StringOf', @DisplayName OUT, 'results[i].watcher.displayName'
        EXEC sp_OAMethod @jResp, 'StringOf', @AccountId OUT, 'results[i].watcher.accountId'
        EXEC sp_OAMethod @jResp, 'StringOf', @AccountType OUT, 'results[i].watcher.accountType'
        EXEC sp_OAMethod @jResp, 'StringOf', @v_Email OUT, 'results[i].watcher.email'
        EXEC sp_OAMethod @jResp, 'StringOf', @PublicName OUT, 'results[i].watcher.publicName'
        EXEC sp_OAMethod @jResp, 'StringOf', @Username OUT, 'results[i].watcher.username'
        EXEC sp_OAMethod @jResp, 'StringOf', @UserKey OUT, 'results[i].watcher.userKey'
        EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'results[i].watcher.details.business.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @PersonalValue OUT, 'results[i].watcher.details.personal.value'
        EXEC sp_OAMethod @jResp, 'StringOf', @spaceKey OUT, 'results[i].spaceKey'
        EXEC sp_OAMethod @jResp, 'StringOf', @contentId OUT, 'results[i].contentId'
        SELECT @j = 0
        EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'results[i].watcher.operations'
        WHILE @j < @count_j
          BEGIN
            EXEC sp_OASetProperty @jResp, 'J', @j
            EXEC sp_OAMethod @jResp, 'StringOf', @operation OUT, 'results[i].watcher.operations[j].operation'
            EXEC sp_OAMethod @jResp, 'StringOf', @targetType OUT, 'results[i].watcher.operations[j].targetType'
            SELECT @j = @j + 1
          END
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @queryParams
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

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