请求Postman工作,但Ruby工作失败

时间:2017-11-06 22:23:32

标签: ruby https postman

我在这里尝试了很多选项,我真的不明白它是什么。

我在Postman尝试这个请求,一切正常:

https://api.airbnb.com/v1/authorize?client_id=d306zoyjsyarp7ifhu67rjxn52tv0t20&username=someemail@test.com&password=secret

但如果我尝试使用红宝石,我会得到:

<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body bgcolor="white">
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>

我的Ruby请求是:

require 'openssl'
require 'uri'
require 'net/http'

url = URI("https://api.airbnb.com/v1/authorize?client_id=d306zoyjsyarp7ifhu67rjxn52tv0t20&username=someemail@test.com&password=secret")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["cache-control"] = 'no-cache'
request["postman-token"] = 'f7cd129c-f7f5-b79a-e829-0ad7f7ebf81f'
request['content-type'] = 'application/x-www-form-urlencoded'


response = http.request(request)
puts response.read_body

0 个答案:

没有答案