How do I get the body of a page via API?

Adrian Germeck February 27, 2018

Hi,

I am using this link

http://example.myhost/rest/api/content/{id}

to get the content of my page.

But how do I get "Content: Person C_Version 01C" (shown below)?

Question.png

1 answer

1 accepted

6 votes
Answer accepted
Lei Wang
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 28, 2018

Hi,

You could read the content of a page with the body expanded.

http://example.myhost/rest/api/content/{id}?expand=body.storage

Please refer to the Confluence REST API examples for more details: https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/

Pavel Potcheptsov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2018

And you'll get Value with unbreakable line which is actually the content of page.

Is it possible to get better formatting?

Like taylor.varoglu likes this
Aishwarya Nandapurkar October 23, 2018

Same question. If the page has an index and links to the sections on the same page. How to directly access the data content on links through the REST API's?

 

To be precise, Say I have a page id 12345, on confluence, if I am accessing :

http://helloworld/wiki/pages/12345/XYZ#XYZ-abcdabcd  this on the url, how do we access the underlined part through REST API?

Like # people like this
bdmicek July 26, 2019

this is what im trying to figure out as well

Robert Raines August 27, 2019

The Atlassian API doesn't have a way to return just the part of the page following an anchor. The best you can do is get the page by the space and title, then parse for the html anchor.

Assuming your URL has a space, like:

https://helloworld/wiki/spaces/SPC/pages/12345/XYZ#XYZ-abcdabcd

I think you would do it with

page=confluence.get_page_by_title('SPC', 'XYZ', expand='body.storage')
content=page['body']['storage']
anees u May 11, 2021

Im getting 404: Page Unavailable error with below REST API call. Kindly help. Any permission issue? I provided Basic Auth in Postman with my username and accesstoken:


http://mypage.atlassian.net/rest/api/content/32991?expand=body.storage

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events