REST Post Request with form-data

0
Hey everyone, I am trying to save a file to an API via a REST function. I am using a Post Request with form-data, which works fine in Postman. In Mendix, hiwever, I get a ‘Bad Request’ Error… Has anyone experienced that before and could help me with a solution? Thank you
asked
4 answers
1

Hi Jonas,

Try to set log level of REST Consume to ‘TRACE’. It will show request message from Mendix.

answered
0

Hey Peeradech,

This is what the log gives me:

Request content for POST request to https://client.freshfields.com/freshfields/api/4/files/content?parentfolderid=1078609 HTTP/1.1
Authorization: (omitted)
Content-Type: multipart/form-data;
    boundary="----=_Part_3_409809153.1586421045033"

------=_Part_3_409809153.1586421045033
Content-Disposition: form-data; name="filename"

Hello
------=_Part_3_409809153.1586421045033—

 

and the response is:

 

Response content for POST request to https://client.freshfields.com/freshfields/api/4/files/content?parentfolderid=1078609
HTTP/1.1 400 Bad Request
Server: Apache
Cache-Control: no-cache, no-store
Pragma: no-cache
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-RateLimit-Limit: 2000
X-RateLimit-Remaining: 1998
X-RateLimit-Reset: 1586421265
X-Ratelimit-Relative-Reset: 220
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Date: Thu, 09 Apr 2020 08:30:45 GMT
Connection: close
Set-Cookie: ROUTEID=.app9b402; path=/freshfields; HttpOnly=true; Secure
Set-Cookie: ROUTEID=.app9b402; path=/freshfields; HttpOnly=true; Secure

{"timestamp":"2020-04-09T08:30:45.294+0000","status":400,"error":"Bad Request","message":"Bad Request","path":"/freshfields/api/4/files/content"}

answered
0

Hi Jonas,

In the header of Post activity add the Content-type (both the key and value)

Hope this works!

answered
0

Hi Jonas,

I think your issue has been fixed in Mendix 8.9.

answered