Draft and posted entities

How can I do to get all the entities, even the draft ones? (from all the endpoint)
I’m making a dashboard that is only for admins, and those admins need to get ALL the entities.
Do I have to make a Rol for those users?

Try to use this parameter

?_publicationState=preview

2 Likes

And what’s the opposite? _publicationState=posted ?
If I do _pulicationState=preview its only returns the ones on draft mode (thanks for that)

It is live and preview

But I don’t know why… i thought it works, but it returns the same entity.
(I have two entities for test, one is published and the other not)

What an idiot, preview return all the entities haha, sorry

FYI we have this documented here: Content API - Strapi Developer Documentation

1 Like

Is there an alternative for the GraphQL api? Seems this only works for REST. @DMehaffy

1 Like

Strapi strikes again!

live: returns only published entries (default)
preview: returns both draft entries & published entries

It would be so easy and so useful to have preview only return drafts and set all as default to return all entries. For anyone interested I think a way to solve this is to use filters:

    let entry = await strapi.entityService.findMany("api::coupon.coupon", {
      filters: {
        publishedAt: {
          $eq: null,
        },
      },
    })

But thanks Strapi for sticking to your basic philisophy of making things as complicated as possible for no reason whatsoever.