I cannot find an example of how to perform a POST request to a server and upload a file using HTTParty. The server (which has an API) expects a file to be uploaded.
The encoding method must be multipart/form-data
Thanks.
I cannot find an example of how to perform a POST request to a server and upload a file using HTTParty. The server (which has an API) expects a file to be uploaded.
The encoding method must be multipart/form-data
Thanks.
In the end what I did was using the RestClient library since it implements the multipart/form-data Content Type.
Although this library uses internally ruby's standard HTTP::Net library, it creates a way to compensate for the missing feature.
I was in shock when I noticed the standard library of Ruby did not come with such a thing out-of-the box.
For anyone interested in exploring other alternatives to this topic/problem, I also suggest you a look at here which is basically a library that gives you the ability to upload files using Net::Http which is nice.
Faraday also allows file upload but I did not test to see how it works so I don't know more than what the documentation mentions about it.