Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove all watches from page programatically

JET CM Folks
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 20, 2021

Hey everyone,

We have a space in our Confluence instance that contains sensitive data that has specific rules around getting sent via e-mail. Since there isn't a good way to natively set watches for a specific Space/Page I'm looking into periodically removing watches programmatically.

I have a way to gather all URLs that have watches, including the page ID, I just need a way to use this information to remove all watches from them.

Here's the SQL to gather the URLs that contain watches in our Controlled space:

SELECT um.username,
CONCAT ('https://www.ourjira.com/wiki/pages/viewpage.action?pageId=', c.contentId) AS URL,
c.title,
s.spacename,
c.contentID
FROM NOTIFICATIONS n,
user_mapping um,
SPACES s,
CONTENT c
WHERE n.contenttype = 'page'
AND n.contentID = c.contentID
AND um.user_key = n.username
AND c.spaceID = s.spaceID
AND s.spacename = 'Controlled';

 This results in a table similar to the following:

watcher_usernamepage_urlpage_titlepage_spacepage_id
user1https://www.ourjira.com/wiki/pages/viewpage.action?pageId=20509496701-06-2016 Sustainment WG MinutesControlled205094967
user2https://www.ourjira.com/wiki/pages/viewpage.action?pageId=20460340201-06-2016 Sustainment WG AgendaControlled204603402

1 answer

1 accepted

1 vote
Answer accepted
Kishan Sharma
Community Champion
October 20, 2021

Hi @JET CM Folks You can remove watchers from a page by using DELETE method to REST API endpoint - /rest/api/user/watch/content/{contentId} 

Please refer this link for the documentation.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events