Preview article using Ghost REST API?

Is it possible to use Ghost’s REST API to query a draft post (to render an article preview)? Currently this preview feature is broken for my application - all pages 404.

I’m using:
GHOST_CLI_VERSION 1.7.3
GHOST_VERSION 1.23.0

One example “Preview” link of a draft post is:
https://neighborly.com/learn/p/0f485b89-fd28-4aac-b4db-e535cb311941/

Compared to a “View post link” link of a published post:
https://neighborly.com/learn/neighborly-and-madison-wi-join-forces-and-lower-denominations-on-community-bonds-so-more-residents-can-support-the-future-of-their-city/

Assuming preview posts are accessible via the REST API, I’m assuming we’d have to create some separate route (i.e. /learn/p/post-id vs. the published post route /learn/post-slug)?

Thanks!

No. Take a look at our public api docs.

1 Like

Ah, ok, thanks Kate. So it looks like that data is accessible via the private API once we acquire a bearer token, is that correct? https://api.ghost.org/docs/user-authentication

That suggests there’s something wrong with your web server config :thinking: Have you done any configuration outside of what Ghost-CLI does for you?

Thanks for checking in @Kevin - the fact that the pages 404 is not surprising to me given that in our application that hits our Ghost API, we haven’t defined any route at /learn/p/post-id, which looks to be the URL generated by default in the Ghost editor for post previews.

Seems the primary failure (as @Kate pointed out) is that post drafts are not accessible via the public API. Looks like we could solve that by using the private API once we acquire a bearer token, is that correct?

This documentation mentions:

In the future this should be possible using Client Authentication.

Any idea where that lies in the Ghost roadmap?

Thanks again!

Correct.

In the future this should be possible using Client Authentication.
Any idea where that lies in the Ghost roadmap?

Not really :expressionless:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.