Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
witek2467yYou should be happy you have response in JSON. I had to work with apis which responded with plain text "ERROR" or something like that :-/
-
I'm trying to do restful api right now and I see more people in devRant rant about this stuff. Man..... devRant is awesome xD
-
Well, you could use it to give the users a client message. It's not standard behavior, but at least tou can use it... :P
-
noder11987y@bittersweet seen that too.. an enum with series of custom error codes and corresponding messages.. it's perfectly fine to use it somewhere else, but not for rest api responses... so, what's the consumer supposed to do ? See if the response is 200, then look into the json for an error, if yes then use the error code attribute ??
-
@noder It's worse. This API gives back actual HTTP codes, just arbitrarily picked ones. 10 for OK, 11 for a validation error, 16 for not found, etc.
And the content is not json or xml... it's key value data in strings with all kinds of smartass separators. -
lotd77757y@bittersweet #define smart_ass_operators
I'm curious lol, worst I've encountered was some game with character stats defined as a pipe separated string with math expressions ..
Eg. 'hp:100^{level}|mp:30*{level}|...' -
siksik2447yOne of the projects I've worked in would only returned 200s. Monitoring that application was dicey.
-
Pshh why would you spend all that time implementing status codes when you could just send back a 200 with an extra little message?!
When I first started my new job it took me quite a while to get used to places that throw 200s nearly regardless of what they should be throwing. 😑😑😑
Request URL: /api/v1/user/53b49b5a30
Request Method: GET
Expected Response:
Status Code: 404 Not Found (as the user is actually not present in the DB)
Actual Response:
Status Code: 200 Ok
Response Content:
{
"status": "ERROR",
"errorCode": "404",
"errorMsg": "User Not Found. Please provide a valid user ID",
"type": "Error",
"userMsg": "User Not Found. Please provide a valid user ID"
}
#extremefacepalm
undefined