我可以在Postman上测试这个文件,但是当我在Python上做这个文件时,它是失败的。目前我正在网络代理的后面工作,所以我已经指定了代理。
这是我正在使用的一组代码:
# specify proxy
proxy = {'https':'https://username:password@01.2.345.6:1010',
'http':'http://username:password@01.2.345.6:1010'}
# specify content
header = {'Content-Type': 'application/json'}
# get input
testFile = open('test.json', 'r')
jsonInput = testFile.read()
requestJSON = json.loads(jsonInput)
# specify url
url = 'http://127.0.0.1:5000/test'
response = requests.post(url, json=requestJSON, proxies=proxy, headers=header)当我检查的状态代码时,我得到了的值response。
发布于 2019-11-21 08:21:58
错误代码403意味着访问您试图访问的页面或资源是绝对禁止的,因为某些原因。如果它在postman中工作,那么您可以从postman获得请求库的确切python代码,并将其与代码匹配以检查差异。
发布于 2022-05-30 09:26:55
清除浏览器cookie有帮助。我正在使用Safari浏览器
https://stackoverflow.com/questions/58970061
复制相似问题