Search code examples
ruby-on-railsrubyruby-on-rails-3httptyphoeus

Error while doing HTTP Request


I am using Typhoeus gem to execute HTTP requests in my rails Application. The request is as follows.

 data = {"auth_token"=>"abcd" ,"employee" => {"method" => "add_employee"}}
 header =  { "Content-Type" => "application/json","Accept"=>"application/json"}
 request = Typhoeus::Request.post("www.example.com",:body=> data.to_json,:headers => header)

here while executing this the auth_token has been converted to auth%5Ftoken=abcd. Actually my API expecting the parameter auth_token. Because of this API is not allowing to access it. It's throwing unauthorized error. Please help me to solve this problem. Thanks in Advance.


Solution

  • I corrected that issue with to_query. Actually to_query is parsing the actual data to the API