Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to identify a space given a pageID.

Due to the format of our page titles, our page URLs always resolve to ../pages/viewpage.action?pageId=########

And people are constantly receiving a URL to a page that results in the error: You don't have permission to view this page. 

This results in numerous tickets to our instance admin to determine the space/admins of the page.

It looks like I could possibly write a user macro to get ancestors (which also might not be viewable by the user) so what I really need is to identify the space or the page admins based on the pageId.

2 answers

Are you looking for a way for your help desk to look up the space based on the page id or are you looking to show that to the user in the permissions message when it shows up?

All the options are interesting, I would like to get the name of the space to grant access to this page.

com.atlassian.confluence.pages.Page page = pageManager.getPage(pageId);
com.atlassian.confluence.spaces.Space space = page.getSpace();

getPage(long id) - Deprecated.
since 7.3.0, we can use ContentService.find(Expansion...) from plugins


com.atlassian.confluence.api.model.content.Content content = contentService.find(new Expansion("space")).withId(ContentId.of(pageId)).fetchOrNull();
com.atlassian.confluence.api.model.content.Space space = content.getSpace();

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

38,270 views 27 125
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you