Http transformer with Multipart/form-data does not send the correct Content-Type header

Hi,

I’m trying to upload images using this API: Item Image
Using the Http transformer for this I’m getting bad request responses because the Content-Type header that is send is not correct. See this log:

Sending request
POST /API/V3/Account/139600/Item/107075/Image.json HTTP/1.1
Content-Type: application/json
Accept: application/json
Authorization: Bearer <REDACTED>
Host: eu.merchantos.com

--6735a5ff53e658.71131631
Content-Disposition: form-data; name="data"

{"ordering":0,"description":"0060178_kpki7076t6e1_1.jpeg"}
--6735a5ff53e658.71131631
Content-Type: image/jpeg
Content-Disposition: form-data; name="image"; filename="0060178_kpki7076t6e1_1.jpeg"

<REDACTED>

The Content-Type header should have been:

Content-Type: multipart/form-data; boundary=6735a5ff53e658.71131631

Is there any way to fix this?

Hi @a.aleman,

You can change the Content-Type by adding a custom header through a plugin on your HTTP client configuration.

If you need a further assistance, please provide me with the link to your configuration through DM.

@r.candrian I’m using the multipart/form-data option from the http transformer, this probably generates this boundary by itself, so I do not know this beforehand. So I cannot add the required header this way.

Please try to create a new header by this on your HTTP Transformer:

Then, since we have an issue with the Lightspeed HTTP Client, create a new HTTP Client with a default prototype.

And please don’t forget to check this option:
image

Thanks, using a http client based on the default prototype seems to work, the header is even fixed automatically.

Great! Happy to hear that.
Another workaround is to remove the default header “application/json” and add a new header “multipart/form-data.”

For this workaround, you didn’t need to create another HTTP Client.