smart-on-fhir / client-py

Python SMART on FHIR client
http://docs.smarthealthit.org
Other
591 stars 211 forks source link

server.py:request data always produces 'NoneType' object is not iterable #129

Closed timharsch closed 2 years ago

timharsch commented 2 years ago

I need to use the request_data function in server.py to get a resource of type Binary. Cerner sandbox returns HTTP 406 for calls to Binary that don't provide Accept header as the required value of "application/fhir+xml" or "application/fhir+json". Per the the R4 spec, these are the expected values. This makes the request_json method unsuitable and we should instead use the request_data function. Calling that function will always yield:

Traceback (most recent call last):
..snip..
  File "/Users/harsch/git/patient-portal/piece/portal_worker/utils/fhirclient_utils.py", line 36, in request_data
    return client.server.request_data(url)
  File "/Users/harsch/.pyenv/versions/WORKER/lib/python3.9/site-packages/fhirclient/server.py", line 176, in request_data
    res = self._get(path, None, nosign)
  File "/Users/harsch/.pyenv/versions/WORKER/lib/python3.9/site-packages/fhirclient/server.py", line 192, in _get
    header_defaults.update(headers)
TypeError: 'NoneType' object is not iterable

The error is on this line: https://github.com/smart-on-fhir/client-py/blob/7196334/fhirclient/server.py#L176

As you can see, my editor shows the headers parameter is not in use. It should have been passed to _get instead of None. image

I will have a PR coming soon that fixes this error.