Answer the question
In order to leave comments, you need to log in
How to send an http post file with parameters using Ruby?
The request should be similar to the one below:
curl -X POST -H "Content-Type:application/octet-stream" "http://example.com/api/v1/data?api_key=API_KEY" --data-binary "@json_file.json"
Answer the question
In order to leave comments, you need to log in
require 'net/http'
uri = URI('http://example.com/api/v1/data?api_key=API_KEY')
req = Net::HTTP::Post.new(uri)
req.body = File.read('json_file.json')
req.content_type = 'application/octet-stream'
res = Net::HTTP.start(uri.hostname, uri.port) {|http|
http.request(req)
}
stackoverflow.com/questions/184178/ruby-how-to-pos...
or
`curl -X POST -H "Content-Type:application/octet-stream" "http://example.com/api/v1/data?api_key=API_KEY" --data-binary "@json_file.json"`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question