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

Identify page from URL

Hi.

 

I am looking into how I can identify a Confluence Page/Content from it's URL.

On the self-hosted server, the page has a reference to the pageid:

<!DOCTYPE html>
<html>
<head>
...
<meta name="ajs-page-id" content="845153134">

But on the cloud-hosted server, I only get that after the JS/ajax was executed.

How can I identify the page on a cloud server with curl?

 

Thanks for the help

1 answer

Hey Oliver, I might misunderstood what you're aiming for but if you want to get the contentid using curl with the title of the page for example you can use the content REST API endpoint.More information here https://developer.atlassian.com/cloud/confluence/rest/#api-content-get

For e.g if the title of the content is "Meeting Notes" you can use curl GET to the following endpoint to get the content id

https://<instance>.atlassian.net/wiki/rest/api/latest/content?title=Meeting%20notes

Hi.

Imagine you have a short URL: https://xxx.atlassian.net/wiki/x/YIkAB.

I want to use https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-get to get the content of the page: https://xxx.atlassian.net/wiki/rest/api/content/{contentId}.

 

My question is: how can I find the contentId of the page without knowing the title or space?

I dont think its possible to get it directly from the existing endpoints. Though i can see that the short URL is returned in the json output so its possible to parse the results using jq to get a list of content id with the matching tinyurl for all content (there's a 500 results limit in the cloud if i remember correctly) with the following command

curl --silent --user <user>:<token> -X GET "https://<instance>.atlassian.net/wiki/rest/api/content?type=page&expand=property" | jq ".results[] | [{ id: .id, tinyurl: ._links.tinyui }]"

walking through all pages on the server is definitely not an option.

Every page as a meta tag which contains the ID of the page:

<meta name="ajs-page-id" content="845153134">

The problem is that the cloud server only adds this tag through JS.

So I have working code for the On-Premise server and am looking on how I can get it to work for Cloud server as well.

Did you say you had the code working for On-Premise server ? Can you share it with us? I'm interested in getting the page ID from REST API knowing only the page url which may by a tiny url only

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,435 views 6 6
Join discussion

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