If I test a postman post request I receive a status code 200 and receive a valid response as expected. When I try to use python’s requests
library I get the following error code:
requests.exceptions.ConnectionError:
HTTPSConnectionPool(host=’myurl.com’, port=443): Max retries exceeded
with url: /RestApi/v1/Authentication/RequestToken (Caused by
NameResolutionError(“<urllib3.connection.HTTPSConnection object at
0x000001A95F827220>: Failed to resolve ‘myurl.com’ ([Errno 11001]
getaddrinfo failed)”))
I tried my own implementation of the python request as well as the suggested code by postman:
import requests
import json
url = "https://myurl.com/RestApi/v1/Authentication/RequestToken"
payload = json.dumps({
"Credentials": {
"Username": "myUser",
"Password": "myPassword"
}
})
headers = {
'Prefer': 'respond-async',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
The requests are made from the same client (my laptop). Any idea why postman works while python fails?
1