I need Confluence Page ID and page owner values using REST api for a given Confluence URL. Is it possible?
Hi Srinivas,
This page has an example of how to get the page ID and creator if you have the URL (which includes the space key and page title):
Please see the heading, "Find a page by title and space key".
There are no page owners in Confluence, but perhaps finding the creator will be of help.
Please let us know any follow up questions.
Thanks,
Ann
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In some case, the page is given with a url with no Title at all. It may be a tiny url. Is there anyway we can get the page Id from that, using REST API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The way I manage around in this case (no title, no space) is to do one extra step to 'get' this tiny url content first, then extract the space, title and id from the metadata content.
They are kept in the attributes with names ajs-space-key, ajs-page-title and ajs-latest-page-id.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Phaneendra chitta: AFAIK - there is no way around to get the page ID from short link except to "open the link" (e.g. via curl) and then read the ID from retrieved page content as described below in the comment from @Partha Kaushik on 24.06.2021.
I don't know - why it should be avoid to retrieve the page content from short link, but if it's really strictly prohibited for some reason - a workaround could be to iterate via REST API through all pages at confluence server (i.e. get all spaces, then within all spaces iterate over all pages and their sub-pages starting from each space-homepage). During the iteration compare the short links of pages with requested one and in this way - get the page ID. But this workaround is really ugly and will take longer as direct download of page content...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is a code snippet in Python:
import os, re, sys, json, requests
# In the page URL, replace the + symbols with %20
confPage = https://confluence.mydomain.com/display/TST/My%20Specific%20Page
auth = (confUsername, confPassword)
headers = { 'Content-type': 'application/json', 'Accept': 'application/json' }
res = requests.get(confPage)
#print (res.content)
matched_lines = [line for line in (res.text).split('\n') if "ajs-page-id" in line]
if len(matched_lines) == 0: exit("Page ID not found")
# Output line example: <meta name="ajs-page-id" content="544428643"> , need that page-id
pageID = (matched_lines[0].split()[2].strip('<').strip('>').split('"')[1])
print (" Page ID: " + pageID)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
confPage = https://confluence.mydomain.com/display/TST/My%20Specific%20Page did not work for me instead I had to use REST end point
confPage = https://confluence.mydomain.com/display/rest/api/content/464194260
Are you sure we can use normal https url that we use in browser in script ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.