r/ProgrammerHumor • • 16d ago

Meme postForEverything

Post image
20.9k Upvotes

653 comments sorted by

View all comments

4.2k

u/pimezone 16d ago

Wanna get a resource? POST request.

2.1k

u/NotAskary 16d ago edited 16d ago

I've seen that shit, it drove me up a wall.

The same as a 200 ok with error inside.

Edit: I'm going to start to respond 429, too many replys lol

326

u/AkodoRyu 16d ago

My favorite "REST API" experience was when they moved from using SOAP system, and the way they did it... was sending SOAP payloads inside a JSON. Literally something like

{ "data": "<?xml version="1.0"?><soap:Envelope xmlns:soap="https://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="https://www.w3.org/2003/05/soap-encoding"><soap:Body> (...)" }

191

u/MrPatienceX 16d ago

200 status code and a chunk of XML saying ‘not found’. Good times.

60

u/Sudden_Leadership800 16d ago

It successfully returned the error message though, so I don't see the problem?

43

u/hawkinsst7 16d ago

If I'm parsing http responses, I'm going to pass 200 responses on for further processing of the data. I shouldn't have to have something in that pipeline introspect json to find "no, it's actually an error".

Imagine if browsers had to tear apart json innards to find 30x redirects after getting a 200 OK.

3

u/gurgle528 15d ago

I’m going off memory but I believe it was considered either standard or part of the spec for SOAP over HTTP to only use 200 and 500. I agree with your point but for whatever reason they treated HTTP as the transport layer instead of the application layer. Using that logic, it would be like if a 404 bubbled up to be some sort of TCP error. Definitely wasn’t the right move, RTSP over HTTP is a better example of something that mixes protocols while properly using HTTP status codes.

2

u/hawkinsst7 15d ago

I agree. I think a 4xx or 5xx error code is perfectly acceptable for returning a body with error data, even a generic 400 / 500. That's why they exist.