Stream: ihe
Topic: PUT vs POST
Jose Costa Teixeira (Sep 05 2017 at 16:46):
Hi. Is there any guidance on using PUT vs POST when pushing a resource for the first time?
I understood that both may be used, one key difference being idempotency so I am wondering how this has gotten solved by others.
Grahame Grieve (Sep 05 2017 at 17:33):
it depends on your id managemnet patterns
John Moehrke (Sep 05 2017 at 17:58):
MHD and NPFS used POST, but they are also posting a Bundle of resources. Not just a singular resource (Create). The other FHIR profiles from ITI are just read only profiles.
Jose Costa Teixeira (Sep 05 2017 at 18:17):
Perhaps we need to use a bundle too.
Scenario: patient syncs his smartphone and this uploads all the pending medicationAdministrations to the server.
This means bundle, right?
Jose Costa Teixeira (Sep 05 2017 at 18:20):
if i get it right, basically either we:
a) leave the IDs for the server to manage, use POST and risk POSTing same thing twice.
b) expect the client to manage their IDs and PUT the things that are not on the server yet.
Is that about right?
John Moehrke (Sep 05 2017 at 19:50):
Yes. The duplicate POST is mostly an academic argument, not found in the wild that much. It can be left to a client choice. But they need to be warned that if they chose to use PUT, they must do proper id management; and they must know the server will allow it. POST is the more common method. So I would recommend you have servers support both methods, and recommend clients use POST. Or just pick POST until you have strong Profile evidence that you must address this.
Last updated: Apr 12 2022 at 19:14 UTC