how to get full content body (html) using confluence REST API ?

Sameer V
Contributor
January 23, 2018

Example API call to get content  - https://<domain>/rest/api/content/12345

I'm not able to find out a way to get the whole content body.  Although, this

{"webui":""...}

gives the URL to get the actual content on the browser, is there no way to get the actual html content in the JSON response itself?

1 answer

1 accepted

31 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.

https://<domain>/rest/api/content/12345?expand=body.storage

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

Sameer V
Contributor
March 1, 2018

That works. Thanks @Lei Wang!

Arjun s
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!
February 18, 2019

That was very helpful!

Rigin Oommen
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!
April 25, 2019

Awesome. 👏 this worked for me

Kimberly Cook
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!
August 22, 2019

How can you search for the content ID?

Like Joel Ransom likes this
Pranesha Bunsee September 27, 2019

If you want the page ID, go to Tools --> Page Information on the particular page you are interested in. You should see the page (content) ID shown in the URL when you do this.

Like Flint Cave likes this
Rafael Ruiz May 18, 2020

I have a question: how can we push HMTL to body?

Like # people like this
Mahmoud Turki
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!
July 1, 2020

thank you

Cliff Berg
Contributor
March 7, 2023

It no longer works. Seems like:

1. The ability to programmatically (using the Forge API) to access a prior version of a page no longer works.

2. The ability to obtain the _content_ of a prior version of a page, even by entering the URL query in a browser, no longer works.

E.g., this does not work using Forge:

 

const vresp = await api.asApp().requestConfluence(route`/wiki/rest/api/content/7208974/version/20??expand=body.storage`, {
headers: {
'Accept': 'application/json'
}
});
...
and neither of these work in a browser:
Old API:
(does not show the body.storage.value - i.e. the content of the page)
...
New API does not seem to have a way to retrieve page content for prior page versions. Docs are here:https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-page/#api-pages-id-get
So I tried this:
(produces page not found)
Like Zames Roh likes this
Lei Wang
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 7, 2023

Hello @Cliff Berg

 

Thank you for the update. The API is designed for Confluence Server and Data Center, and not for Confluence Cloud. I have performed a quick test and can confirm that it is still functional in Confluence Server/DC 7.19 LTS.

 

Best,

Lei

Cliff Berg
Contributor
March 7, 2023

Thanks for the reply. That clarifies things.

Does that mean that for Confluence Cloud, there is no way to obtain the actual content of an earlier version of a page?

I just tried these in a browser, and the body field that is returned is an empty string (but the actual body should not be empty):

https://agile2academy.atlassian.net/wiki/rest/api/content/7208974/?body-format=atlas_doc_format&version=37

https://agile2academy.atlassian.net/wiki/rest/api/content/7208974/?body-format=storage&version=37

 

I also tried this,

https://agile2academy.atlassian.net/wiki/api/v2/pages/7208974/versions/37/

but the response does not even have a body field.

 

Thanks.

Like # people like this
Olexiy Kovtunenko
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!
April 22, 2024

@Cliff Berg what worked for me was using this: 

...../wiki/api/v2/pages/1234567?body-format=ATLAS_DOC_FORMAT

Like # people like this
Priten Vora
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!
June 19, 2024

Thank you, that helped a lot!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events