ERROR 5400: Bad request: Error parsing form fields In Node

I am using Node and I am getting an error trying to upload to Cloudflare images. This was working about a week ago but suddenly broke. I am using the "<ACCOUNT_ID>/images/v1" endpoint and it works via cURL but I am getting a ERROR 5400: Bad request: Error parsing form fields error when I try to execute the same function through node.

The post call looks like:

await fetch(<ACCOUNT_ID>/images/v1, {
      method: 'POST',
      headers: {
        'Content-Type': `multipart/form-data`,
        Authorization: `Bearer ${api key}`,
      body: formdata,

The formdata is super simple and I only have


After I make this request, I get ERROR 5400: Bad request: Error parsing form fields

The formdata is simply just a new FormData()

To clarify, the error message above was when I tried to make the same request with axios, but with fetch the error code is the same but the message differs a bit

ERROR 5400: Bad request: multipart/form-data Content-Type has invalid syntax: lacks boundary

I think this error message might be a better representation of the situation for the code I provided

And if I remove the content-type itll give me this error:

ERROR 5415: Must be uploaded as a form, not as raw image data. Please use multipart/form-data format

This topic was automatically closed after 15 days. New replies are no longer allowed.