Unexpected error with multipart request
I'm not sure if this is expected but I was working with an API expecting a multipart upload and it tripped up whenever I would set the content type header according to the documentation. The below snippet exhibits the same behavior.
Not setting the content type header resulted in a successful request.
I don't fully understand why but thought I'd raise as feedback.
(http/post "https://postman-echo.com/post"
{:headers {"Content-Type" "multipart/form-data"} ; < -- this made the request fail
:multipart [{:name "title" :content "My Title"}
{:name "file" :content (io/file test-file) }]})
I'm not familiar with this API but what was the error you got back from the API?
The reason this happens is that when using multipart, the content type should be something like "multipart/form-data; boundary=babashka_http_client_Boundary7f8662ac-e551-4a60-9be3-786d7743724a" which is what babashka.http-client adds automatically. When not specifying the boundary, the API will send back a 500 that says that the boundary is missing. To solve this issue, we could dissoc "Content-Type" or so.