Error Converting Curl Request to Net::HTTP
set_form_data
will encode the request payload as www-form-encoded
. You need to simply assign the body directly.
uri = URI('https://xxxxxxxx.ws/authenticate')https = Net::HTTP.new(uri.host,uri.port)https.use_ssl = truereq = Net::HTTP::Post.new(uri)req['Content-Type'] = 'application/json'req.body = { username: 'foo', password: 'bar' }.to_jsonres = https.request(req)