HTTPoison Post multipart/form-data with fields only

Hello I’m new to elixir and I’m doing a client request of HTTPoison, but I can’t seem to find a figure out multipart/form-data with only fields submitted

I don’t want to upload file or any, I just want to append the fields and make a POST request

an example of simple HTTPoision request

HTTPoison.post "http://httparrot.herokuapp.com/post", "{\"body\": \"test\"}", [{"Content-Type", "application/json"}]

The underlying Erlang hackney library has some docs that suggest using :form instead of :multipart if there is no file to upload.

1 Like

You could try the following:

HTTPoison.post("http://httparrot.herokuapp.com/post", {:multipart, [{"body", "test"}, {"body2", "test2"]}, ["Content-Type": "multipart/form-data"])

Hope it works for you or anyother person who may have same issue :slight_smile:

6 Likes