Getting 404 when trying to hit the API endpoint
Closed this issue · 3 comments
Hello!
This is my setup in plugins.ts:
'preview-button': {
config: {
contentTypes: [
{
uid: 'api::content.content',
draft: {
url: 'http://localhost:1337/api/preview',
query: {
type: 'content',
slug: '{slug}',
},
},
},
],
},
},
but trying to reach the unpublished article with slug: fasdfasdf at the link http://localhost:1337/api/preview?type=content&slug=fasdfasdf gives me 404. How to get the JSON response from Strapi for the drafts of type content?
My local server runs on http://localhost:1337
Env info
│ Time │ Thu Jun 29 2023 16:42:50 GMT+0200 (Central Euro… │
│ Launched in │ 682 ms │
│ Environment │ development │
│ Process PID │ 80393 │
│ Version │ 4.11.1 (node v18.15.0) │
│ Edition │ Community │
│ Database │ sqlite
After more research I figured out that the correct way to request will be http://localhost:1337/api/contents?publicationState=preview
Hello How did you solve this problem? I encountered the same problem.
I added publicationState=preview
to my API call