D
David Sainte-claire
Hello,
I'm sure this is a newb question, but I've spent the last two hours
trying to figure out how to set the query paramters on an HTTP GET
request.
Right now I am doing something like this:
def call()
Net::HTTP.start(@base_url) do |http|
response = http.get(@uri)
puts "Code = #{response.code}"
puts "Message = #{response.message}"
puts "Body = #{response.body}"
end
It works as long as I include the query parameters as part of the @uri
string, but to me that doesn't seem like an elegant approach.
I could just append the parameters to the end of the URI as part of the
call() method (right now it has no parameters, but I could change it to
something like call(params) which accepts a hash and manually append
them to the URI before calling the GET method.
I'm just hoping that there's an easier, or more standard way of doing
it.
Anyone ever run into something similar and has an elegant solution?
I'm sure this is a newb question, but I've spent the last two hours
trying to figure out how to set the query paramters on an HTTP GET
request.
Right now I am doing something like this:
def call()
Net::HTTP.start(@base_url) do |http|
response = http.get(@uri)
puts "Code = #{response.code}"
puts "Message = #{response.message}"
puts "Body = #{response.body}"
end
It works as long as I include the query parameters as part of the @uri
string, but to me that doesn't seem like an elegant approach.
I could just append the parameters to the end of the URI as part of the
call() method (right now it has no parameters, but I could change it to
something like call(params) which accepts a hash and manually append
them to the URI before calling the GET method.
I'm just hoping that there's an easier, or more standard way of doing
it.
Anyone ever run into something similar and has an elegant solution?