I am new to python and I am trying to automate post API in which I am using post method as follows:-
headers = {'Content-Type': 'application/json',
'Authorization': 'Basic xxxx=='}
response = requests.post(url=urlsales, data=payload,
headers=headers)
After running the test, getting the following output :-
print("response headers >>>>", response.headers)
response headers >>>> {'Date': 'Fri, 30 Oct 2020 14:11:34 GMT', 'Content-Type': 'application/json', 'Content-Length': '187', 'Connection': 'keep-alive', 'X-Error-Code': '500.45.001', 'Access-Control-Allow-Methods': 'GET,POST,OPTIONS,PATCH,DELETE,PUT', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Accept, Accept-Encoding, Authorization, Content-Length, Content-Type, Host, User-Agent, X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto'}
print("headers >>", headers)
{'Content-Type': 'application/json',
'Authorization': 'Basic xxxx=='}
I am assuming there is issue with headers as when I send only 'Content-Type': 'application/json' in header , then i get 401 unauthorized which is as expected but when I add 'Authorization': 'Basic xxxx==' as mentioned above I start getting 500 internal server error
can someone please help with the possible root cause where it might have went wrong