1

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.

5
  • 403 error come when its forbidden means access denied. Check your details which you passing for authentication or check how you passing authentication header to api Commented Nov 21, 2019 at 8:17
  • @aviboy2006 I've checked the authentication details, they're correct! What do you mean by 'check how you passing authentication header to api' though? Commented Nov 21, 2019 at 8:53
  • in postman you are doing using authorisation or passing proxy ? You may be doing in postman using authorisation. Try this quora.com/… Commented Nov 21, 2019 at 8:56
  • @aviboy2006 I'm doing neither of them but I'm able to get it to run on API hmm... Commented Nov 21, 2019 at 9:05
  • @aviboy2006 I've tried adding in the authentication details but I'm still getting the error 403 :/ Commented Nov 21, 2019 at 9:15

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I copied the codes from postman and ran the codes but I'm still running into the same error :(
Recheck your headers.
0

clearing browser cookies helped. I am using Safari browser

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.