Python OPTIONS / GET请求

时间:2016-12-14 19:16:12

标签: python httprequest python-requests http-status-codes

过去几个小时我一直坚持这一点。无法解决这个问题。我在邮递员身上测试了它,它运行正常。但在python中,我一直收到405个请求。

原始API请求

OPTIONS /sessions HTTP/1.1
Host: elb.deposit.shopifycs.com
Access-Control-Request-Method: POST
Origin: https://checkout.shopifycs.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Access-Control-Request-Headers: content-type
Accept: */*
Referer:
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

url = 'https://elb.deposit.shopifycs.com/'
resp = session.options(url, headers = Headers)
print resp.status_code, ' status'

1 个答案:

答案 0 :(得分:0)

只是为了记录,答案是使用正确的URL。

url = 'https://elb.deposit.shopifycs.com/sessions'

(我希望发布一个答案会阻止其他人花太多时间看它)