views:

15

answers:

1

Hey guys,

Just a quick question,

when I do

request = Net::HTTP::Post.new(path)

Can I do

path = '/api/v1/baskets?apiKey=' + api_key + '&sig=' + sig + '&time=' + time

Where api_key sig and time are some string

or do I need to do

path = '/api/v1/baskets'
request.set_form_data({'apiKey' => api_key, 'sig' => sig, 'time' => time})

is there any difference or are they pretty much the same?

A: 

They are pretty much the same, set_form_data does a urlencode.

Here is what it does in set_form_data link

def set_form_data(params, sep = '&')
  self.body = params.map {|k,v| "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" }.join(sep)
  self.content_type = 'application/x-www-form-urlencoded'
end

When in doubt always refer ruby-doc.org.

Amit