Patching an item between "draft" and "published"

Hello,

I have created a lot of items as drafts. Now I’d like to publish/stage them. I have tried patching them with attributes:
{ ‘_draft’ = false}
and
{‘_draft’ = false} and ‘?live=true’
but neither changes its status from draft.

Do I need to stage/publish the items manually now? Or is there a way to do it with Patch Item or a different API call?

Thank you!

edited: true → false

Isn’t it
"_draft": false

1 Like

oops, yes I meant to say I have been trying "_draft": false with no success.

I have the same problem

I can’t toggle _draft false/true no matter what I do

In case its not solved yet → You have to use updateItem instead of patchItem to toggle from draft to published item. Furthermore, you have to set live=true in the updateItem API Call.

BR

1 Like

Same problem here, trying to auto draft / undraft ecommerce products:

  • patching product (from ecommerce) with {“_draft”: false} or {“_draft”: true} does nothing (aka _draft value unchanged, either before or after manual publish, either with ?live=true or without)

  • patching collection item (of product collection) with {“_draft”: false} or {“_draft”: true} does nothing (either with ?live=true or without)

  • PUT collection item (of product collection) is refused by webflow if I PUT all the fields "{“msg”:“User is not authorized to perform this action: Cannot complete operation for the ecommerce collection [Produits] with this endpoint.”,“code”:403,“name”:“ForbiddenError” (either with ?live=true or without)

  • PUT after removing read-only fields (published-by, published-on, updated-by, updated-on, created-by, created-on ,_id, _cid) is also refused by webflow(either with ?live=true or without) (same 403 error)

  • even a PUT with only {‘_draft’: True} is refused by the same 403 error on the product collection

I do not find any solution to update via API the draft status of an ecommerce product. I’m quite sure it was working some times ago, but since at least november it stopped working.
This is very painful for us, forcing us to update manually each product.

1 Like

Any solution for this? Currently having this issue trying to set “_draft” to true

Also having the same issue that @Mike929 is having.

@Thomas_Chiroux, @Mike929 & @Bailey_Simrell - It actually is a PUT request that you need to do with the live = true param with ONLY the base required fields that the system assigns to the collection:

In my case (standard CMS collection), that would mean: name, slug, _draft & _archived. Here is the js if that helps:

const options = {
  url: `https://api.webflow.com/collections/${bundle.inputData.collection_id}/items/${bundle.inputData.item_id}`,
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': `Bearer ${bundle.authData.access_token}`,
    'Accept-Version': '1.0.0'
  },
  params: {
    'live': true
  },
  body: {
    'fields': {
      'name': `${bundle.inputData.item_name}`,
      'slug': `${bundle.inputData.item_slug}`,
      '_draft': false,
      '_archived': false
    }
  }
}

return z.request(options)
  .then((response) => {
    response.throwForStatus();
    const results = response.json;

    return results;
  });

If you’re building something like this in Zapier or integromat, you’ll need to pass of that info in so you either need to build dynamic inputs that do calls in the background OR do a leading call to just pull the item’s info (much easier). PUT + base config (fields) + live=true is what the API interprets as a base change rather than a content change (my phrase, not webflow’s - but I think you get what I mean).

Hopefully that helps you on your quest! I don’t have an ecomm site and I know that ecomm collections are a little different, but there should be some analog if it isn’t exactly this. Cheers.

-Bry