rest-client / rest-client

Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions.

Home Page:https://rubydoc.info/github/rest-client/rest-client/master

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request.execute Strips My Request Domain?

firrae opened this issue · comments

Hi there!

So I'm having a really strange issue currently. Below is an example of my request definition:

request = RestClient::Request.new(:method => :get, :url => 'https://some.local.server/api/v1/datatypes', :headers => digestHeaders, :payload => params.to_json, verify_ssl: false)

In my logs I can see the following:

Request object: <RestClient::Request @method="get", @url="https://some.local.server/api/v1/datatypes">
Request headers: {:"content-type"=>"application/json", :accept=>"application/json", :"signed-headers"=>"host,signed-headers", :host=>"this.apps.url", :"x-api-key"=>"0123456789", :Authorization=>"auth token"}
Request uri: #<URI::HTTPS https://some.local.server/api/v1/datatypes>

Now when I use request.execute I get the weird behaviour. I'm seeing it actually call: this.apps.url/api/v1/datatypes. What is really weird is this style of generation works elsewhere in our application, but this specific one just seems to choke for some reason.

The next line in my dev logs is the following

ActionController::RoutingError (No route matches [GET] "/api/v1/datatypes"):

indicating it circled back on itself rather than going to the other address.

Any ideas would be appreciated.

Looks like it was the format I defined my headers in. It seems fine now that I've modified them to look like:

{"content-type":"application/json", accept:"application/json", "signed-headers":"host,signed-headers", host:"this.apps.url", "x-api-key":"0123456789", Authorization:"auth token"}