Reputation: 63
I'm able to test this file on Postman, however it is failing when I'm doing it on Python. I'm working behind a network proxy at the moment so I've specified the proxy.
This is the set of codes that I'm using:
# specify proxy
proxy = {'https':'https://username:[email protected]:1010',
'http':'http://username:[email protected]: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)
I'm getting a value of 403 when I check for the status code of response
.
Upvotes: 1
Views: 8457
Reputation: 350
Error code 403 means that accessing the page or resource you were trying to reach is absolutely forbidden for some reason. If it is working in postman then you can get exact python code of request library from postman and match it with your code to check the difference.
Upvotes: 2