HTTP Post in ruby NoMethodError -
i trying make http post using require 'net/http' here request
token_url = 'http://www.[url].com/oauth/token' uri = uri(token_url) req = net::http::post.new(uri) req.basic_auth env['oauth_id'], env['oauth_password'] req.set_form_data({ 'grant_type' => 'client_credentials' }) resp = net::http.new(uri.host, uri.port).start {|http| http.request(req) } json.parse(resp.body)['access_token']
i keep getting error: nomethoderror - undefined method 'empty?' #<uri::http:0x007fb2ed01bdf8>:
this happens on line "req = net::http::post.new(uri)
". ideas why?
figured out:
replace
req = net::http::post.new(uri)
with
req = net::http::post.new(uri.request_uri)
Comments
Post a Comment