Forums

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

Confluence watch pages pragmatically

Tanya Gordon -HP-
Contributor
November 1, 2018

Hi community,

Can anyone please share a code snippet for a confluence REST EndPoint that adds a given user as a watcher on a given page/content?

I've been struggling with the existing documentation and API but couldn't get to a solution...

Any contribution would be welcomed!

Thanks a lot,
Tanya

1 answer

0 votes
Tanya Gordon -HP-
Contributor
November 5, 2018

Answering to myself :-)

For string parameters: user, pageId

import com.atlassian.confluence.mail.notification.NotificationManager
import bucket.user.UserAccessor
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager

def notificationManager = (NotificationManager) ContainerManager.getComponent('notificationManager')

def userName = userAccessor.getUser(user)
Page page = pageManager.getPage(pageId)
def content = page?.getContentEntityObject()
notificationManager.addContentNotification(userName, content)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events