Cannot access draft page via REST API

Hi everyone,

I’m trying to retrieve a Confluence page that has not yet been published, but already has an id. While editing the page, its url is

https://xyz.atlassian.net/wiki/spaces/EAS/pages/edit-v2/201031681?draftShareId=606d49d4-d32a-48b6-93ec-24257c8a8681,

so the id of the draft is 201031681. I try to retrieve the page via GET /rest/api/content/201031681?status=draft, but the response is http 403.

When I want to retrieve an already published page, there is no problem and I get http 200 with the data in the response, which means that my scopes in the descriptor and my jwt signing is fine.

Are non-published pages invisible to the rest api? I don’t see any note about it in the docs. And why the 403 code?

Thanks a lot for any advice!

1 Like

We have this problem too, but for macros on a draft page. Would love to see REST API support here.

I was able to successfully retrieve a draft page by making a 3LO call. I haven’t tried reproducing this by calling the app using JWT authentication. To help investigate further, perhaps you could try from the front end using AP.request.

I am able to retrieve draft pages as well. What I can’t seem to do is to get a macro body from the API (https://developer.atlassian.com/cloud/confluence/rest/#api-api-content-id-history-version-macro-id-macroId-get) for a page that is in draft status :frowning:

@BobBergman, my guess is that the query filters out draft pages just like get content by ID does unless status=any is specified. Unfortunately, it seems the get macro body by macro ID doesn’t accept a status parameter.
@VojtechSchlemmer, instead of passing status=draft to the get content by ID method, perhaps try passing status=any.

I spent my afternoon trying to workaround the lack of the status param on the get macro body api by trying to manually extract it from a draft page (which is inefficient, but I had hoped it would work – it didn’t). Sadly, it seems that Confluence doesn’t send a valid macro id in edit mode (at least for fabric) that can be used to find the macro in a draft mode page. In fact, the draft mode of the page doesn’t really seem to reflect the current state of the page in the editor at all, at least not immediately.

I will try status=any.

No luck with any, either.

FWIW, my use case is for rendering a dynamic content macro in the fabric editor without wholly rewriting our apps to use a more client-heavy approach that can use the client side AP.confluence.getMacroBody, which does work. When CONFCLOUD-65861 was fixed today I hoped to be able to use it to provide a better UX in fabric, but am now blocked trying to request the macro body from the server when Confluence send the request to render a given macro id. There doesn’t seem to be a way to get the macro body to satisfy the request.

I have finally managed to retrieve the Draft page. All I had to do was using user impersonated call (User impersonation for Connect apps) together with status=draft at the url. Thank you @dmorrow for your advice. Nevertheless the 3LO call cannot be used with Atlassian Connect apps, we are supposed to use user impersonation instead, as the documentation says.

1 Like