How to create content in draft mode through Rest APIs

I have a Next.js based frontend. I want my users to create content, but it should be created in draft mode, through Rest API. And, some moderator will eventually publish it.

I find no way in rest API to create content in draft mode.

Is there a way to do this?

1 Like

Hey mate, you can do it like;

const body = {
 name: 'x',
 description: 'y',
 published_at: null
}

request("/endpoint", { method: “POST”, body })

It works for me

2 Likes

Thanks for the reply. I got that working earlier, could not post.
But, the solution you proposed can be altered by client(user). As, it is all at client side. I wanted something at backend.

So, I modified controller and by default put this published_at to null in create call.

Thanks

As of 7th February, the field is written publishedAt and not published_at as said before. So you would do like this:

const body = {
 name: 'x',
 description: 'y',
 publishedAt: null
}
request("/endpoint", { method: “POST”, body })
2 Likes

I get an error "“Invalid format, expected a timestamp or an ISO date” when setting publishedAt to null.

1 Like

Same here. I am wondering if it should be undefined or null.