Return very minimal REST responses to avoid 204 No content codes.
Description
blocks
relates to
Activity
Sebastian Iancu last week
notes from a REST API meeting 2024:
try with prefer=identifiers
2024-08-28: consider aligning with FHIR specs on the flow, consider (minimal, representation, identifier); minimal remains as 204 not-content, identifier is status 200/201 as very simple object with identifier; or text/plain (via Accept) with only id
consider the case of error-representation and OperationOutcome
Ian McNicoll August 28, 2024 at 3:26 PM
I found this FHIR Chat discussion which crosses into today;s discussion https://chat.fhir.org/#narrow/stream/179166-implementers/topic/OperationOutcome.20code.2Fdetails.20for.20specific.20use.20cases/near/450280310
Ian McNicoll August 5, 2024 at 12:23 PM
Iām coming back to this, as it continues to raise questions/confusion from new openEHR developers. We are making this harder than it should be for newbies.
Iām happy to accept that 204 no-content responses are perfectly reasonable and I think Pablo is on the right track in saying that the issue is that we have no definition of āminimalā, which allows no-content and therefore may generate a 204.
So either we try to agree that āminimal' should be standardised and return some sort of actual response, at the very least a status message, or if people want to allow for a non-content response/ local variation, then we add a new 'standardā response type, which does return a standard, agreed response and is the default.
Anything we can do to lower the barrier of entry, IMO.
Pablo Pazos June 3, 2024 at 1:53 PM
@John Meredith the spec says this depends on what the client (developer) sends in the request, in the Prefer header. If they send Prefer: return=minimal then itās up to the server to return a minimal representation or no content. If itās a POST, the minimal representation will return 201 Created, the no content will return 204 No Content, which are both HTTP standard response codes. To work with this developers should know the openEHR REST API spec and the HTTP spec for the response codes. If someone is confused by that, it might be that they are not familiar with either of those. IMO the 201 vs 204 is very clear and I donāt think is a real issue. The only argument I have is about the minimal representation which I think is not 100% standard, though we show samples in the REST API spec. It would be nice to standardize what we expect for the minimal representation.
John Meredith June 3, 2024 at 11:23 AMEdited
Apologies for adding to an old issue but this is causing very real confusion to our development teams where there is the expectation for a 201 and details on the resulting composition that has been created. Iād appreciate this being looked at although returning a more detailed ack message in the 204 would equally be useful.
The current REST responses do not enforce any complelty minimal responses so that 204 No content is returned that in my experience confuses developers.
In many case too there is some minimal valuable content e.g. the ehr_id or composition_uid which is oftne used for the next stage of processing. THis is currently returned in the ETag header but this is often obscure instead REST libraries and requires the quote marks to be stripped.
Suggested v. minimal responses...
/composition
POST - the new uid
PUT - the updated uid
DELETE - the deleted uid
/ehr
POST - the new ehr_id
PUT - the ehr_id
/definition/template
POST - the new templateId, uid and dateCommited
PUT - the updated templateId, uid and dateCommited
DELETE - the deleted templateId, uid and dateDeleted
/query - an empty Resultset array?
I'm aware that might be at odds with 'proper' Restful design but the current 204s are quite confusing.