Parameters Missing

282 views
Skip to first unread message

Johnathon Wright

unread,
Apr 9, 2013, 12:00:43 PM4/9/13
to httpar...@googlegroups.com
Please verify that I understand how this should work.

class Service
  include HTTParty
  base_uri 'domain.com'
end

Service.get("/url", {'a' => 'b'})

should result in something like


but instead it results in



Here are my logs:


74.80.33.74 - - [09/Apr/2013:11:56:38 -0400] "GET /?a=b HTTP/1.1" 302 102 "-" "curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3"

Service.get('/", {'a' => 'b'})

74.80.33.74 - - [09/Apr/2013:11:58:12 -0400] "GET / HTTP/1.1" 302 102 "-" "-"

# of course, this works, but if that was your intent, why provide the second parameter?

Service.get('/?a=b")

74.80.33.74 - - [09/Apr/2013:11:58:51 -0400] "GET /?a=b HTTP/1.1" 302 102 "-" "-"

This happens in 1.8.7(mri), 1.9.3(mri) and 1.9.3(rbx) using httparty 0.10.2

David Nichols

unread,
Jun 26, 2013, 2:04:24 PM6/26/13
to httpar...@googlegroups.com
Hi Johnathon,

You are supplying url parameters to the options hash. The options hash provides a number of ways to customize a specific request, such as:

:body - http body to send
:headers - headers to attach to the request.
:query - url parameters to use within the uri.

I would suggest taking a look at the Request class within HTTParty.

You would want:

Service.get('/", :query => {'a' => 'b'})

Dave
Reply all
Reply to author
Forward
0 new messages