Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RESTful- Which HTTP Status to Return on False

I have a RESTful service where I need to return a boolean equivalent. If the query returns true, I will return a 200 status, but am not sure what to return on false. I was thinking it should be a 4** status, but which one? Would 404 be considered the most appropriate?

Thanks!

like image 794
sdoca Avatar asked Dec 12 '22 08:12

sdoca


1 Answers

You should return 200 on both cases. Then return a content-type header of text/plain and include the string "true" or "false".
Most languages should have no problem parsing those strings into a native type.

like image 92
Darrel Miller Avatar answered Dec 28 '22 07:12

Darrel Miller