UploadImage To REST API error MineType

0
Hey all, I try to upload an image to a REST API. If I do it from postman it works but not from Mendix. I get the following response: HttpError 422 {"error_translatable":"Invalid mimetype","type":10,"title":"Unprocessable Entity","status":422,"detail":"error.api.upload.invalid-mimetype"} The difference I see is the content-type in the form-data but I can’t find this in Mendix. If I look at the request from Mendix it looks like this:   Request content for POST request to https://xxx.api.xxx.xxxx.tech/upload HTTP/1.1 Authorization: (omitted) Accept: application/json, text/plain, */* Accept-Encoding: gzip, deflate, br Connection: keep-alive Content-Type: multipart/form-data;      boundary="----=_Part_4_648412434.1616113866684" ------=_Part_4_648412434.1616113866684 Content-Type: application/octet-stream Content-Disposition: form-data; name="file"; filename="testimage19/09/2021 01:09:00.jpg" ����JFIF``��-<ExifMM* &b1&�2 In PostMan the CURL:   POST /upload HTTP/1.1 Host: stella.api.bike.conneq.tech Authorization: Bearer at_E6fBjFqrfNv0F1W4jlXFWTfA9FcEh Content-Length: 199 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ----WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="/G:/Downloads/background_main.jpg" Content-Type: image/jpeg  
asked
3 answers
2

Replying to this old post, because Studio Pro 9.3 has just been released with a new feature: you can now specify headers for the different parts of the form-data request. So that allows you to set Content-Type: image/jpeg.

answered
1

It looks like te service requires you to pass the header Content-Type: image/jpeg in the file part, is that true? Mendix form-data doesn’t allow you to set that header to anthing other than application/octet-stream

answered
0

it looks like you are passing the file name not a file.

answered