Why am I Receiving a 400 Error when Updating a CMS Item using Webflow's API?

This topic was automatically generated from Slack. You can find the original thread here.

Hi, I’m trying to update a CMS item using Webflow’s API, but keep getting a 400 error. I’m not sure where I’m going wrong, as all of the field names seem to match up, and I can’t figure it out with anything online.

I’ve attached a screenshot of my Webflow CMS setup, and the docs for the Webflow API are available here: Update Collection Item

Thanks

Hi Iarla,

Welcome - happy to have you. Does the 400 error include a response body? Perhaps you can expand it within the Exports tab of your Webflow step after you’ve tested it, that might give more detailed information

Thanks Pierce, the Exports tab is greyed out, but the exact error is:

AxiosError
Request failed with status code 400

at null.settle (/tmp/pdg/dist/code/eb31736e88c8fda23f7129b5441830edfa897355eedc523fedbed796547d415c/node_modules/.pnpm/axios@1.6.2/node_modules/axios/dist/node/axios.cjs:1967:12)
at IncomingMessage.handleStreamEnd (/tmp/pdg/dist/code/eb31736e88c8fda23f7129b5441830edfa897355eedc523fedbed796547d415c/node_modules/.pnpm/axios@1.6.2/node_modules/axios/dist/node/axios.cjs:3062:11)
at IncomingMessage.emit (node:events:529:35)
at null.endReadableNT (node:internal/streams/readable:1368:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

That’s too bad, usually the API will return a better error message than that.

Are you using a pre-built action? Or Node.js/Python code to perform this API request?

Prebuilt action, let me send a picture of the whole step

Thanks, much appreciated. I believe I see the issue. The Custom Fields prop isn’t being populated with any data.

Could you try hard coding this data instead of using the dynamic data from the Data Store as a test?

I just want to narrow down the possibility of a bug within the action itself

Good spot, was using an old variable, unfortunately it still doesn’t work after fixing it

Got it, and just to clarify, are you using the Webflow - Update Collection Item action?

From what I can tell, Custom Fields is supposed to be an array, not a single object like you shared in the latest screenshot.

I’m not sure what your newest inputs look like, but I would wrap them in handlebars for JS evaluation and make sure I’m passing an array of objects:

{{ [ { Count: 85 } ] }}

I’m using the Webflow - Update Collection Item action

And I’m using the “Construct an Object” tab for inputting the Custom Fields value, so it should be an array already

I’ll try manually putting in {{ [ { Count: 85 } ] }}

Sorry, I was mistaken, it is in fact supposed to be an object. But I believe I see the issue now

The arguments don’t look like they’re being passed correctly to the webflow Node.js client

What do you mean by that sorry?