Topics

GET with deep parameters

Jack Repenning <jrepenning@...>
 

rest-client (1.6.7)

I need to pass a multi-level hash in as parameters to a GET call. I see a discussion about this in the archives already,

http://librelist.com/browser//rest.client/2010/7/24/rest-client-passing-parameters-on-get-request/#a5a6253f3d005bcb28f836fe4b5b24eb

but that solution only seems to work a level or two deep; below that, the Hash remains stringified. Am I doing something wrong?

Some details:

credentials = {
:developerOrganization => "jreptest",
:developerKey => "1c9e3deaffd264823e553935bbf238117ff2f88d",
:domain => "jreptest",
:login => "jreptest",
:password => "password"
}
RestClient.get url, {:params => {:credentials => credentials}}

is logged by Rails as

Parameters: {"credentials"=>"{:developerOrganization=>\"jreptest\", :developerKey=>\"1c9e3deaffd264823e553935bbf238117ff2f88d\", :domain=>\"jreptest\", :login=>\"jreptest\", :password=>\"password\"}", "id"=>"102"}

Notice the quoting: the hash whose first key is :developerOrganization is still stringified.

In contrast, this works (but makes me feel dirty ;-):

# Monkey-patch RestClient to define get_with_payload
module RestClient
def self.get_with_payload(url, payload, headers={}, &block)
Request.execute(:method => :get, :url => url, :payload => payload, :headers => headers, &block)
end
end
RestClient.get_with_payload url, :credentials => credentials



-==-
Jack Repenning
Technologist
CollabNet, Inc.
8000 Marina Blvd., Suite 600
Brisbane, CA 94005
O: 650.228.2562 | F: 650.228.2501 | Skype: JackRepenning
E: jrepenning@...

www.collab.net

Enterprise Cloud Development
10,000 customers, 3.6M users, 1M paid subscribers