我可以在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
时,得到的值是403。你知道吗
错误代码403表示由于某种原因,访问您试图访问的页面或资源是绝对禁止的。如果它在postman中工作,那么您可以从postman获得请求库的确切python代码,并将其与您的代码匹配以检查差异。你知道吗
相关问题 更多 >
编程相关推荐