Hi all, ![]()
I have noticed inconsistencies amongst NERM APIs.
GET /api/user_managers results in 200 OK with error message: no managers found
GET /api/advanced_search results in 400 Bad Request with error message no advanced searches found (shouldn’t the endpoint here be called advanced_searches plural? That is what the documentation demands at least)
GET /api/identity_proofing_results results in 404 Not Found with error message no identity proofing results found
This is inconsistent behavior meaning we would need to change our scripts for each different object type.
I would like to suggest the following result when no objects exists:
It should result in 200 OK with empty array as response [].
Benefits:
- All object types behaving the same makes it more predictable and user friendly
- It should be
200 OKbecause the API could do what it should do: list all objects in an array. This can be an array with 10 objects, and array with 2 objects, and array with 1 object and an array with 0 objects. A400 Bad Requesterror would suggest we gave the wrong input, which we didn’t. And404 Not Foundshould be used in case we specifically refer to an object that does not exist, for example by callingGET /api/users/1234....56789. - An empty array
[], instead of a value such asnullorERRORwill allow us call alength()orsize()method on it to get 0 as result. In addition we would not need to perform unneeded edge case handling if we want to iterate over the results. For iterating overnullorERRORwill go wrong, whereas iterating over[]will do exactly as expected: Perform 0 iterations. - In addition, if the url parameter
metadata=truewas passed along, we would expect the_metadatain the body, even if there were no objects.
Kind regards,
Angelo