Requesting update state from published to draft

Hi,

I am new in Strapi and would like to unpublish certain contents via API. I didn’t find if it is possible to change a content from published to draft state with an update request. I’m trying to do that with Python and seems not to be possible, at least updating ‘published_at’ field with Python’s native None value or sending a ‘null’ value as string. Am I wrong about this? Is there any way to make a draft from plublished content as if I did at web interface?
Thanks in advance
Gustavo

1 Like

Hi! Did you manage to work this out - is it even possible? I want to make this ops as bulk but can not find a way via API also.

EDIT:
Now it works for me - my issue was that I tried to update “published_at” and is should have been “publishedAt” :slight_smile: Docs could be a bit more clearer here!

const query = {
  where: {
    id: ids[0]
  },
  data: {
    publishedAt: (operation === "publish") ? new Date().toISOString() : null
  }
}

await strapi.db.query('api::product.product').update(query)
1 Like