Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Identify page from URL

Oliver Lipkau March 5, 2018

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

0 votes
Nazri Muhi April 2, 2018

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

Oliver Lipkau April 3, 2018

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?

Nazri Muhi April 4, 2018

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 }]"

Oliver Lipkau April 4, 2018

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.

Hung Nguyen February 25, 2020

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

Like Phil likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events