2

HTTParty.get 多次向它发送的 URI 添加参数。有没有其他人遇到过这个?

def initialize(address)
   self.address = address
   self.base_uri = 'https://api.randomapi.com/street-address'
end

def get
  response = HTTParty.get(base_uri, :query => {
    :street => address.street.strip,
  })
end

如果这是我以这种方式格式化请求:

HTTParty.get(base_uri, :query => {:street=>"random street"})

这是发送的 URI。street注意参数被添加 了多少次。

#<URI::HTTPS:0x007fbc78582d70 URL:https://api.randomapi.com/street-address?street=random%20street&street=random%20street&street=random%20street&street=random%20street>
4

1 回答 1

1

原来这是 gem 中的一个错误(https://github.com/jnunemaker/httparty/issues/185https://github.com/jnunemaker/httparty/pull/189)。我升级到 0.11 并修复了重复参数问题。

于 2013-10-11T19:34:09.383 回答