I'm taking a course in which we need to access a public FHIR endpoint. I'm trying to do this via Python, but am receiving a 407 AuthenticationRequired response, when this is supposed to be a public server.
I've checked with the course administrators and have been assured this is supposed to be a public server. I am able to easily process a get request via my browser (note this is all fabricated patient data): if I access the URI http://fhir.hl7fundamentals.org/r4/Patient/17120, I get an expected response within my browser.
HTTP 200 OK Response Headers X-Powered-By: HAPI FHIR 3.7.0-SNAPSHOT REST Server (FHIR Server; FHIR 4.0.0/R4) Content-Type: application/fhir+xml;charset=utf-8
Response Body { "resourceType": "Patient", "id": "17120", "meta": { "versionId": "22", "lastUpdated": "2020-07-31T03:55:59.144+00:00" }.....
When I try a get request to the same resource via Python, I get AuthenticationRequired.
import requests
r = requests.get('http://fhir.hl7fundamentals.org/r4/Patient/17120')
r.content
Out[24]: b'<!--Title-->\nAuthenticationRequired\n<!--/Title-->\n<!--Content-->\n407\n<!--/Content-->'
If this is a public server, this implies I may be doing something wrong on the Python side of things - any thoughts on what I might be doing wrong or why I get AuthenticationRequired?
?_format=xmlto the URL I get valid XML. Are you running the Python code from the same machine as the browser? - Dan-Dev