I have a design dilemma in deciding the response status code and architecture for a middleware we are designing.
So the Client Calls MiddleWare, And middleware calls the 3rd party service to get car-values for a particular car-reg.
If everything goes right and we get car-value, we are sending the status code as 200.
But what if we did call out to 3rd party, we received 200 from them, but it did not have car-value that we want, shall we pass 200 status code back to the client or give a different status code.
The argument given by my middleware team to give 200, is its not an issue its just no data from 3rd party so status should be 200 and a status field in JSON response to tell, the values could not be found.
Which feels quite wrong, if I am client, If I don't get car values, how can it be 200 for me?
EDIT: It's a get request where I pass Car Reg in URL params, I want car value, so anything other than car value is kinda error or failed request for me?
400
means "[the] server could not understand the request due to invalid syntax". If you are getting a200
back from the third party, then a400
from your middleware seems wrong to me.204
(no content). I personally would go for200
. But there's no right answer to this.204
IMO would usually be used in some sorts of PUT operations or stuff alike, when you want to inform the client that it needn't move away from the current page/doesn't need to refresh the current page's content. But yeah,200
is probably the way to go in this case.car-value
then do respond 404 (keep trying). If it can operate without then 200 + empty value is ok.