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

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.

2 Likes

Dear @ruchirbaroniagmailco

you must append the body-format parameter to the call like /api/v2/pages/98383?body-format=storage.

Best regards

Andreas

4 Likes

Thank you!!

Perfect, thanks Andreas! Surprisingly hard to find this answer in the docs (if it exists)

1 Like