Can we use PATCH to update just one field in a collection?

(EDITED: We figured out how to update a collection item with an image field)

Is there a way we can use PATCH to update just the inventory field in a collection?

Thanks!

(ccing @nathan )

We don’t currently have support for a PATCH endpoint, but off the top of my head I can’t think of any good reason on why we couldn’t have one. I will add an issue for it internally and see about getting it implemented!

Excellent! Thank you.

There are a lot of different interpretations of how PATCH should be done (json diffs, etc), but for our API we’ve just decided to allow for name value pairs and partial JSON snippets of just the fields to be updated. Works out rather well.

Did a minor workaround using ES6 spread operator for our blog site Progress.org:

const items = webflow.items({ collectionId: ids.collections.articles }, { limit: 1 })
items.then(i => {
	const item = i.items[0]

	// Do stuff. Then, modify item as seen in line below, using `email` field as example
	let itemToUpdate = { ...item, email: true }

	// Remove `_id`, and other fields that cannot be modified.
	delete itemToUpdate['_id']
	delete itemToUpdate['updated-on']
	delete itemToUpdate['updated-by']
	delete itemToUpdate['created-on']
	delete itemToUpdate['created-by']
	delete itemToUpdate['published-on']
	delete itemToUpdate['published-by']

	// Finally, update item.
	const updateItem = webflow.updateItem({
		collectionId: ids.collections.articles,
		itemId: item['_id'],
		fields: { ...itemToUpdate }
	})
	updateItem
		.then(i => console.log(i))
		.catch(err => console.error(err))
})
.catch(err => console.error(err))