Forums

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

Is there a way to get the page information with the Confluence Rest API by the TinyUrl identifier?

Ricardo Augusto Brito Dantas March 10, 2022

Trying to use the Confluence Rest API to get some information about some pages shared internally in our company by the links. But only have the tiny URL, there is any way to get the page information from the API with this information?

For example, this is the tinyUrl https://company.com/x/D9KBF , using x/D9KBF to get the page information. I know that when I get the page information there is a field called _links that contains the tinyUrl information.

2 answers

1 accepted

0 votes
Answer accepted
Ricardo Augusto Brito Dantas March 10, 2022

Was able to get the pageId from the tinyUrl identifier, thanks to this article https://confluence.atlassian.com/confkb/how-to-programmatically-generate-the-tiny-link-of-a-confluence-page-956713432.html

Rahul Raj
Contributor
August 23, 2022

@Ricardo Augusto Brito Dantas Can you please share the code here. I am looking for similar solution but not able to decode tiny url to get the page id. Thanks in advance!

Ricardo Augusto Brito Dantas August 23, 2022
def _get_confluence_page_id_from_tiny_url(self, tiny_url):
page_short_id = tiny_url.split("/")[-1:][0]
page_short_id = (
page_short_id.replace("/", "\n").replace("-", "/").replace("_", "+")
)
padded_id = page_short_id.ljust(11, "A") + "="
decoded_id = base64.b64decode(padded_id)
return struct.unpack("L", decoded_id)[0]
Like # people like this
Rahul Raj
Contributor
August 23, 2022

@Ricardo Augusto Brito Dantas I tried the code but it is giving an error:

Traceback (most recent call last):

return struct.unpack("L", decoded_id)[0]
struct.error: unpack requires a buffer of 4 bytes
Rahul Raj
Contributor
August 23, 2022

It's working after changing to

return struct.unpack("Q", decoded_id)[0]
Thank you!
Like # people like this
0 votes
Fabio Racobaldo _Herzum_
Community Champion
March 10, 2022

Hi @Ricardo Augusto Brito Dantas ,

welcome to the Atlassian community!

are you talking about Confluence API or Confluence Rest API?

Ricardo Augusto Brito Dantas March 10, 2022

It's about the Confluence Rest API.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events