How to get title and link from my public page via API?

Equipe Desenvolvimento
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 26, 2019

Hello!
How can I get the title and link of my Confluence pages through the API?
I would like to get via JavaScript or PHP.

2 answers

1 vote
Sven Schatter _Lively Apps_
Atlassian Partner
December 27, 2019

How about using the get content by id REST API? Example frontend JS:

var pageId = '12345';
var url = AJS.contextPath() + '/rest/api/content/' + pageId;

$.get(url).done(function(response) {
var links = response._links;
var pageUrl = links.base + links.context + links.webui;
var pageTitle = response.title;

console.log(pageTitle, pageUrl);
});

Theoretically you don't even need to build the URL from the response object. You could just append the pageId to "/pages/viewpage.action?pageId=" to get the link.

Best regards,
Sven

0 votes
Neil
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 7, 2020

The Confluence Cloud API documentation has details about the GET content method, along with some code snippets for Node, Python, and PHP.. and curl. 

https://developer.atlassian.com/cloud/confluence/rest/#api-api-content-get

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events