Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location header is ignored during create/update methods #24

Open
bktrinadh opened this issue Feb 15, 2017 · 4 comments
Open

Location header is ignored during create/update methods #24

bktrinadh opened this issue Feb 15, 2017 · 4 comments

Comments

@bktrinadh
Copy link

Hi,

REST specification returns a Location header on successful POST/PATCH and has to be handled appropriately by the caller.. The create()/update() methods are successful with HTTP 201 but the response does not return the actual object reason being the Location header is ignored..

Snip from server.py->post_json()

    res = self.session.get(url, headers=headers)
    self.raise_for_status(res)
    return res

Snip from fhirabstractresource->create()

    ret = srv.put_json(self.relativePath(), self.as_json())
    if len(ret.text) > 0:
        return ret.json()
    return None

Here fhirabstractresource is getting all the headers since it receives a Response object but ignores the response headers. The return response is always None on successful creation since REST does not return any data on success..

Thanks
Trinadh.

@p2
Copy link
Member

p2 commented Feb 15, 2017

This is what FHIR has the Prefer header for. This behavior is not implemented, happy to accept a pull request.

@bktrinadh
Copy link
Author

I was talking to one of EHR Provider on "Prefer" header and their answer is that it is not mandatory according to specs that it should be honored.. But Location header with the reference to newly created Object will always be set.. Is there a design that you have thought of how it should be handled based on whether data is present or use Location header?

@p2
Copy link
Member

p2 commented Feb 17, 2017 via email

@p2
Copy link
Member

p2 commented Feb 17, 2017

p.s.
In the Swift client we have a method create() that sets Prefer: return=minimal and does not return a resource, and we have createAndReturn() which sets Prefer: return=representation and which issues an additional GET request should the server not honor the Prefer header before returning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants