Forums

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

How can I access Confluence Page Content through the Confluence REST v2 API?

ruchirbaronia_gmail_com
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!
March 3, 2023

I am a community developer trying to build a Confluence app that must scrape textual page content. I am having trouble getting the actual page content.

 

I am able to successfully query pages using the pages endpoint (GET /wiki/api/v2/pages)

 

Here is the output

 

results: [
{
id: 98383,
version: [Object],
authorId: '6237c985ee1b5a0070273f6b',
title: 'Overview',
status: 'CURRENT',
body: {},
parentId: null,
spaceId: 98306,
createdAt: '2023-01-25T09:40:17.506Z'
}
...]

Notice here that body is empty! I have also tried using the solution here by trying to use the deprecated content endpoint, along with optional parameter `?expand=body.storage`

 

/wiki/api/v2/content/98533?expand=body.storage

 

This leads to a scope error:

{ code: 401, message: 'Unauthorized; scope does not match' }

 

I feel I have the right scopes, as I have reviewed the documentation extensively:

scopes:

- read:page:confluence

- read:content:confluence

- read:custom-content:confluence

- read:confluence-props

- read:confluence-content.all

- read:content-details:confluence

 

Can someone guide me here? I would really appreciate guidance on retrieving post content.

1 answer

1 vote
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 3, 2023

Hi @ruchirbaronia_gmail_com , welcome to the Community!

You're on the right track - the API endpoint you have will return the content if you specify the format you want the body in (either storage or atlas_doc_format) as the body-format query parameter. You can do this with either the /pages endpoint itself to get this for multiple pages at once, or by ID as you had in your example:

/wiki/api/v2/pages/98533?body-format=storage

If you pull the atlas_doc_format type, you can use this documentation and example libraries to parse the format as you need.

Cheers,

Daniel | Atlassian Staff

IPTV KODI
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!
May 4, 2023

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events