d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Restful Api Endpoint > Suggestions Welcome
Add Reply New Topic New Poll
Member
Posts: 5,167
Joined: Nov 23 2006
Gold: 11.01
Jun 21 2017 11:48am
I'm interfacing with a REST api right now that has an endpoint that processes 2 "different" sets of input.

For example:

Code
{
data: {},
timing: 123.45
}


is valid to send but so is:

Code
{
error: {some error},
}


When you pass in the first example you get a "200" back for "successful" calls. For the second example you get a "4xx" status code back which is a "success".

Does this seem weird to you? Is it acceptable to return a 4xx status code for something that you consider "successful"? I would be expecting a 204 (no content) back on successful processing of this error. Should this even be one endpoint when you're essentially processing 2 different models?!
Member
Posts: 36,123
Joined: Jul 18 2008
Gold: 2,407.00
Jun 21 2017 01:17pm
I would not return 4xx for success.
Member
Posts: 1,039
Joined: Jul 8 2008
Gold: 1,939.50
Jun 22 2017 09:41am
4xx are for client errors not for success. If an error is returned 4xx seems correct
Member
Posts: 5,167
Joined: Nov 23 2006
Gold: 11.01
Jun 30 2017 06:58am
Quote (Mastersam93 @ Jun 21 2017 02:17pm)
I would not return 4xx for success.


That's what I'm thinking. No matter what I send to you if you return a 4xx I'm thinking that I did something wrong.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll