How to render content using Confluence REST API

Hi,

I am trying to create a React project to display page content from a Confluence page.
However, the response to APIs like wiki/rest/api/content/{contentId} gives an adf document which is not able to load media and macros because the internal api calls to api.private.atlassian.com.xxx fail with error.

Is there some library I need to use along with atlaskit to ensure success in internal api calls?

Thanks,
Dan

Hi @SpandanRoy, as for getting the content of a page in a different format, try using the expand=body.view query parameter in your request URI. That result payload will include page content rendered in HTML. More info on expand options can be found in the docs.

Can you elaborate on what you mean by internal API calls?

Hi @nmansilla,

I have tried using expand=body.view but it returns incomplete css.
Hence I’m using body.atlas_doc_format which returns an adf document corresponding to the page which I’m rendering to HTML using @atlaskit/renderer.

By internal api calls, I mean api calls to https://dt-api.dev.atl-pass.net/items when renderer tries to load media on my app. Text content seems to load fine but media doesn’t load and I see repeated attempts to this API fail in Network Tab of dev tools.

Please let me know if I need to share further details.

Bumping this up for visibility. @nmansilla, could you please help out here?

Hi @SpandanRoy, did you find a solution for this?

Hi @Ka1ne .
I’m not the OP, but we use the convert content REST api https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-content-body/#api-wiki-rest-api-contentbody-convert-to-post to render the html
It only works within Confluence, but it’s a start

AP.request({
            url: "/rest/api/contentbody/convert/view?contentIdContext=" + contentId + "&expand=webresource",
            type: "POST",
            data: JSON.stringify({
                value: adf,
                representation: "atlas_doc_format",
            }),
            contentType: "application/json",
        });
1 Like