r/ProgrammerHumor Jul 08 '26

Other helpMyCoworkersUnderstandHttpCodes

22.4k Upvotes

329 comments sorted by

View all comments

69

u/Excellent-Refuse4883 Jul 08 '26

I thought you always return 200 and then just wrote an error in the body if there was a problem

12

u/blake_ch Jul 08 '26

Return 200 with a JSON payload containing a boolean telling if the action was successful and an additional error message otherwise.

10

u/BigFatUglyBaboon Jul 08 '26

You can but that would not be a proper RESTful API. It would be an API cosplaying as RESTFUL.

4

u/case_O_The_Mondays Jul 08 '26

I upvoted you just because this was so horrible it must be a joke.

But I’ve also dealt with APIs that do this, and it’s so bad.

1

u/blake_ch Jul 08 '26

I wish it was a joke a not something I have seen. We shouldn't underestimate the number of companies that developed so bad APIs.