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
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'key', '<string>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'username', '<string>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'accountId', '<string>'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://your-domain.atlassian.net/wiki/rest/api/user/watch/content/:contentId', @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
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.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)
-- {
-- "watching": true
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @watching int
EXEC sp_OAMethod @jResp, 'BoolOf', @watching OUT, 'watching'
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 "key=%3Cstring%3E"
-d "username=%3Cstring%3E"
-d "accountId=%3Cstring%3E"
-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/user/watch/content/:contentId
Postman Collection Item JSON
{
"name": "Get content watch status",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/user/watch/content/:contentId?key=<string>&username=<string>&accountId=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"user",
"watch",
"content",
":contentId"
],
"query": [
{
"key": "key",
"value": "<string>",
"description": "This parameter is no longer available and will be removed from the documentation soon.\nUse `accountId` instead.\nSee the [deprecation notice](/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details."
},
{
"key": "username",
"value": "<string>",
"description": "This parameter is no longer available and will be removed from the documentation soon.\nUse `accountId` instead.\nSee the [deprecation notice](/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details."
},
{
"key": "accountId",
"value": "<string>",
"description": "(Required) The `accountId` of the user to be queried for whether they are watching the content. The accountId uniquely\nidentifies the user across all Atlassian products. For example, `384093:32b4d9w0-f6a5-3535-11a3-9c8c88d10192`."
}
],
"variable": [
{
"key": "contentId",
"value": "<string>",
"type": "string",
"description": "(Required) The ID of the content to be queried for whether the specified user is\nwatching it."
}
]
},
"description": "Returns whether a user is watching a piece of content. Choose the user by\ndoing one of the following:\n\n- Specify a user via a query parameter: Use the `accountId` to identify the user.\n- Do not specify a user: The currently logged-in user will be used.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Confluence Administrator' global permission if specifying a user, otherwise\npermission to access the Confluence site ('Can use' global permission)."
},
"response": [
{
"name": "Returned if the requested watch status is 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/user/watch/content/:contentId?key=<string>&username=<string>&accountId=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"user",
"watch",
"content",
":contentId"
],
"query": [
{
"key": "key",
"value": "<string>"
},
{
"key": "username",
"value": "<string>"
},
{
"key": "accountId",
"value": "<string>"
}
],
"variable": [
{
"key": "contentId"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"watching\": true\n}"
},
{
"name": "Returned if;\n\n- The calling user does not have permission to view the\ncontent.\n- A user is specified via a query parameter and the calling user is\nnot a Confluence administrator.\n- No content exists for the specified `contentId`.",
"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/user/watch/content/:contentId?key=<string>&username=<string>&accountId=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"user",
"watch",
"content",
":contentId"
],
"query": [
{
"key": "key",
"value": "<string>"
},
{
"key": "username",
"value": "<string>"
},
{
"key": "accountId",
"value": "<string>"
}
],
"variable": [
{
"key": "contentId"
}
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
},
{
"name": "Returned if no `contentId` is specified.",
"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/user/watch/content/:contentId?key=<string>&username=<string>&accountId=<string>",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"user",
"watch",
"content",
":contentId"
],
"query": [
{
"key": "key",
"value": "<string>"
},
{
"key": "username",
"value": "<string>"
},
{
"key": "accountId",
"value": "<string>"
}
],
"variable": [
{
"key": "contentId"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}