Hi Dev Forum,
I see that the Requisition Service responds with a JSON error message that does not follow our documented conventions. JSON and links below with details.
Is there a reason we changed our convention? Do we need to either update our convention or go back and update Requisition Service to follow the pre-existing convention?
JSON today from a Requisition Service 400 Bad Request:
{
"requisitionLineItems": "requisition.error.validation.reasonNotInRequisitionReasonList: Requisition cannot be saved because of adjustment reason with id d9aa0af6-f7f8-4aab-908f-15c660493be5 not being present on the list of allowed reasons."
}
Error Handling Convention JSON:
{
"message" : "Action prohibited because user does not have permission at the facility",
"messageKey" : "requisition.error.prohibited.noFacilityPermission"
}
OpenLMIS Error Handling Convention:
Perhaps the reason for changing the JSON structure was to allow an Array of multiple errors returned on a single request. Our conventions document still has that flagged under "Future: Arrays of Messages" as something we need to establish a convention for. If we are going to make a convention for that, I would still suggest we want the messageKey and the message string as separate properties in the JSON so that API consumers can get each piece without parsing/regex'ing a string.
-Brandon