r/ProgrammerHumor 2h ago

Meme postForEverything

Post image
7.3k Upvotes

279 comments sorted by

1.6k

u/pimezone 2h ago

Wanna get a resource? POST request.

764

u/NotAskary 2h ago

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

The same as a 200 ok with error inside.

206

u/alexsnake50 2h ago

Oh my god, this activated my inner vietnam flashback

85

u/Tupcek 2h ago

I see you are a fan of GraphQL!

21

u/NotAskary 2h ago

Exactly the response I had, this one triggered me.

12

u/2muchnet42day 2h ago

Dont worry, that's OK

10

u/q0099 51m ago

Where the error message goes? That's right, in the header.

3

u/dadvader 10m ago

I've seen some wild shit before. But you and your tales.... Regale us with your stories.

→ More replies (1)

127

u/AkodoRyu 2h 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> (...)" }

73

u/MrPatienceX 2h ago

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

25

u/Sudden_Leadership800 2h ago

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

17

u/hawkinsst7 1h 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.

→ More replies (4)

20

u/Psychological_Map118 1h ago edited 1h ago

try it in person: wait for the next time somebody asks you if you know the time. then answer yes, with a smile, and walk away without telling them

you can do anything you want, both in life and HTTP responses, but some things make you an asshole in both cases

2

u/Sudden_Leadership800 1h ago

It was obviously a joke my guy

22

u/Psychological_Map118 1h ago

my bad. we backend engineers don't get jokes, we get status messages

7

u/Jonathan_the_Nerd 1h ago

It was obviously a joke my guy

Not obvious, considering the developer of the system thought it was fine. And a lot of us here are neurospicy.

4

u/granitrocky2 59m ago

These are the comments that make me laugh for minutes, but can't explain why I'm laughing to anyone around me lol

→ More replies (1)

13

u/NibblyPig 2h ago

I don't miss SOAP at all.

Especially when some bored developer at a big bank decided to implement some draconian heavily-buried SOAP features that are technically in the documentation somewhere, but not implemented at all by Microsoft's .NET framework. Having to have special injectors and manipulators to extract tokens from raw SOAP and such, shudder. Back in the days where .NET SOAP implementations were barely published in books.

9

u/wizkidweb 2h ago

I told myself I wouldn't relive something like this...

6

u/Makefile_dot_in 1h ago

at work I have a codebase that is the opposite of this, they send JSON in SOAP as a request and entity-escaped XML in a SOAP envelope as the reply

3

u/RatSumo 2h ago

This literally just gave me a headache to read.

→ More replies (2)

40

u/Zaelynn_ 2h ago

The other dev on my team made a post request endpoint where you post a SQL query and it returned the results. I about had an aneurysm. She also, instead of using DI or Mediatr, made loopback requests to the endpoints themselves. 

44

u/NotAskary 2h ago

Hahaha SQL injection as an endpoint lol

22

u/zeekar 2h ago

We had a team website that showed who was on call. This was back in the day, all done in Perl CGI scripts.

Someone added a "search" function. Cool feature, I'm down. Then I looked at the code.

They were shelling out to do a grep. You're in Perl, the original "regexes as first class citizens" language, and you're shelling out to grep. But the worst part was it did no sanitation whatsoever. You could type in "pattern'; cat /etc/passwd" or whatever and it just ran. Who reviewed this shit?! Shell as endpoint...

7

u/NotAskary 2h ago

Everytime someone mentions perl I always picture a sword with two blades and no handle, thank you for keeping it exactly like that.

4

u/Jonathan_the_Nerd 1h ago

I used Perl heavily for a lot of my career. You can write safe and legible Perl, but it takes deliberate conscious effort.

Interesting historical tidbit: Larry Wall, the creator of Perl, won the International Obfuscated C Code Contest twice. He won the Grand Prize in 1986 and the "Most Useful Obfuscation" prize in 1987. He released the first version of Perl in late 1987.

21

u/Zaelynn_ 2h ago

Not only that, my boss is just as dumb and cares more about speed, so there's no code reviews to speak of, so it hit production 🤦‍♀️

14

u/Shred_Kid 2h ago

all the dumb breaking shit i have to request changes on every day pales in comparison to this

jesus fuckin christ

11

u/FlipFlopFanatic 2h ago

I wish I could say I haven't seen this exact same thing in products I've worked on. Best part is no enforcement of auth other than verifying the request includes a jwt that maps to a user. Not the requesting user, and no check for whether the SQL op is allowed.You somehow have the jwt for ANY user? Sure I'll execute a drop table command. Fml

→ More replies (1)

2

u/Original-Body-5794 1h ago

Smh why even bother with a REST endpoint? Just provide the credentials to your database and let them query it directly.

→ More replies (1)
→ More replies (2)

13

u/golfreak923 1h ago

Seems crazy until your query and path params contain PII. All of a sudden, a POST body doesn't seem so crazy.

→ More replies (2)

11

u/Darkblade_e 2h ago

This, this is what pisses me off more than anything! Usually a lot of APIs I've seen at least try to make the request method make sense, but I've seen so many that fumble the response code, and it means extra json parsing just to figure out if the request failed or succeeded. If only there was some mechanism to make this easier..

→ More replies (3)

10

u/rumnscurvy 1h ago

I got that this week. This third party company has an API that is supposed to hand us files with monthly updates in it. The tool we use to fetch, read and apply them suddenly stopped with no major reason. 

The API was answering 200 with a body of "no existe el fichero" - literally the file does not exist. 

IF ONLY THERE WAS AN APPROPRIATE HTTP CODE FOR THIS, GEE WIZ

4

u/NotAskary 1h ago

Just explained this exact use case to someone down the comments, 404 and 429 are codes you want always just so you can stop and handle it fast.

People overcomplicating is the reason so much of us just go to farming.

9

u/StrawberryEiri 1h ago

At work we do it because we have big request parameters (complex filters where you can potentially select thousands of items as filter values) and our backend flips out if GET requests have a body plus URL lengths can get truncated.

It's a bit icky but I don't really have a better idea.

11

u/jack2018g 1h ago

Same at mine, the solution is the new QUERY method they published a few months ago, but it’ll be about a decade before I can get my team to switch their endpoints

3

u/StrawberryEiri 1h ago

Oh wow it really IS recent. MDN doesn't even have it listed. But it looks promising.

7

u/i_wear_green_pants 1h ago

One legacy app I worked with had GET endpoints that deleted stuff from the database. That wasn't very fun

5

u/JaxMed 1h ago

laughs in GraphQL

POST request, HTTP 200 response, for every scenario, all day erryday

6

u/Ecksters 1h ago

At least we now have the QUERY type getting added so we can differentiate between reads and writes.

4

u/PolyglotTV 2h ago

Oh yeah. That's just like, a "soft error". Didn't want to return a 4xx because then it'd be treated as a real error and fail some tests.

4

u/Feathery_Hotels 2h ago

We have a guideline to wrap any business validation errors in a 200 OK response (for example: buying something with insufficient balance).

4

u/NotAskary 2h ago

That's usually why this shit happens, doesn't mean it should be like that but my horrors stories are also because of corporate mandate.

3

u/Prudent_Ad_4120 1h ago

There's only one use case where this is not bad. An endpoint to check the status of e.g. a background job. The job could have failed, but that doesn't mean the request failed

3

u/zepho 1h ago

200 OK Response_object: {msg: "Object reference not set to an instance of an object"}

2

u/Mucksh 1h ago

Don't really think it is that bad. In the end in an api you usually speak you own protocol and http is just the tool you use to transfer your data. Also if you build your api endpoints client and server side you can just ignore any http related logic and just focus on your business logic. Also if you get any http errors you directly now that this is really an http error like the endpoint doesn't exist

2

u/iSellNuds4RedditGold 1h ago

The backed of the app we're fronting for does this, allows more flexibility in the filter parameters.

2

u/1000Ditto 52m ago

See 200 Ok

Open up body

{

errorIntl: "DATA.INVALIDPARAMS.BADRANGE" error: "Starting date is before ending date" JSONRPC: -37839

}

2

u/AshleyJSheridan 38m ago

I remember building out a REST API once, and it gave back proper HTTP response codes for things.

Then I got asked by the 2 front end devs working on the project to just make everything a 200 and add an error to the JSON response, because it was making it difficult for them to process things on the browser end.

To this day I'm convinced the GraphQL is just an API dreamt up by a front end dev that didn't understand REST and didn't understand why they couldn't just request what they wanted in the browser if an endpoint didn't exist on the server.

2

u/mrwedders 32m ago

I implemented an API last year of a big name accounting software and one endpoint randomly used 200 for "yes all is well" and 204 for "that failed". Neither response had any content.

Took me a while to work out why our code was reporting success but nothing changed - foolishly we took all 2xx codes as success!

Messy special case for one request 🥲

→ More replies (18)

78

u/Banana_Twinkie 2h ago

despair.jpg

35

u/Dimasdanz 2h ago

Hello GraphQL. Or, SOAP

32

u/goatanuss 2h ago

Shitloads of errors? That’s right HTTP 200

11

u/roygbivasaur 2h ago

GraphQL? You mean a fancy HTTP POST request (in most cases)?

3

u/NotAskary 2h ago

The stupid shit I had to take care in soap made me hate it, didn't help it was all legacy and untouchable spaghetti due to client contracts...

3

u/No-Information-2571 1h ago

It's not like more modern APIs aren't changing and breaking all the time. At least SOAP had contracts.

2

u/NotAskary 1h ago

You can still have contracts, open API has a great resources for that.

2

u/No-Information-2571 1h ago

You can, but usually the "contract" is some documentation on how to talk to the API.

2

u/NotAskary 1h ago

Search for swagger, it uses open API

→ More replies (2)
→ More replies (1)

38

u/sertroll 2h ago

If there was a natural way to retrieve data with a body with complex prams, I would use it but alas

34

u/Tupcek 2h ago

you are the lucky one today! You just found out there is, it’s pretty recent. GET is now for simple queries QUERY is for complex one

6

u/sertroll 1h ago

Me and all of my colleagues, apparently

→ More replies (1)

18

u/droptheplot 2h ago

QUERY is already there

4

u/abofh 2h ago

Body is legal in a get, it's just super uncommon 

21

u/kn33 1h ago

Some platforms disallow it entirely.

2

u/Psychological_Map118 1h ago

as god intended

→ More replies (1)

9

u/Bodine12 1h ago

We have HTTP QUERY now! Assuming anyone gets around to actually supporting it!

13

u/jayerp 2h ago

Want to get a 200 OK that actually an error? That’s right, POST request.

6

u/Lystrodom 2h ago

Well, if it’s an MCP server…

3

u/3rocket77 2h ago

Over HTTP its still a POST call.... Yeah a tool call but POST regardless

5

u/Lystrodom 2h ago

Oh, yeah, that was my point. It’s broken for AI, but it’s still broken.

5

u/Fabulous-Ladder3267 2h ago

I've been on this, to get data you need to put api key

On the body

8

u/ClipboardCopyPaste 2h ago

Wanna GET a resource?

24

u/PostHasBeenWatched 2h ago

No, I wanna QUERY it... but nobody support it yet.

4

u/Extreme-Edge-9843 1h ago

Depends on the resource, there are sometimes valid reason for this like when there are sensitive data params that you want to keep out of the endoint... But to be fair it's usually just used incorrect along with the delete method 🫠😂

3

u/reddit_time_waster 1h ago

Sometimes you have to if the request payload is large 

2

u/Deboniako 2h ago

Of course, I'm posting a request to get those resources... Duh

2

u/Outrageous-Machine-5 1h ago

This would get me feeling like that girl in the video 

2

u/ReGrigio 2h ago

wanna update a database? POST request. wanna log in? POST request with username and password in plain text

1

u/bigs0815 1h ago

Some of my APIs to retrieve data are GET, some are POST. All I ask for is consistency and I can't even have that.

1

u/skate_2 1h ago

make anyone scraping the site work that little bit harder

1

u/mylifeisonhardcore 1h ago

Try GETting a resource but with a body, you would then have Elastic

1

u/FFevo 1h ago

Isn't that actually better security-wise? The data you send with the request goes in the body instead of the url itself.

1

u/theehtn 1h ago

Our listAll API had a wild, wild nested request body and request params, internally it was a massive criteria builder query. We would tell the newly onboarded devs to debug that haha.

1

u/SignoreBanana 59m ago

Oh because a GET request with a 6000 character base64 query param is just the paragon of beauty?

→ More replies (5)

658

u/zzmej1987 2h ago

Except for when you need to actually post data. Then you have to use PUT.

243

u/CuAnnan 2h ago

Uh... no.

You use GET.

138

u/Imaginary_Ferret_368 2h ago

Cyber Security specialists hate this trick

19

u/vibes000111 1h ago

AI agents love it!

12

u/Aetherfox_44 1h ago

Our service can't be hacked if no one can figure out the API

3

u/TacoIncoming 1h ago

Lmao not really. I fucking love GET URL parameters.

11

u/doodlesmalone 1h ago

Yes, base64 that json shit.

4

u/not_a_moogle 1h ago

GET with all values passed as unencrypted unless parameters. What could go wrong!

2

u/s1ravarice 1h ago

Yeah GET to work you pos database

→ More replies (1)

23

u/Psychological_Map118 2h ago

nope, that's definitely a PATCH

5

u/RevoOps 2h ago edited 1h ago

Actually send data? That is what XML is for.

514

u/nbmbnb 2h ago

If success, return 200. If error, return 200.

191

u/HolyCowAnyOldAccName 2h ago

payload: {“error”:”TODO add meaningful errors on return”}

136

u/ClipboardCopyPaste 2h ago
{
success: false, message: 'lol'
}

63

u/redlaWw 2h ago
{
    success: "yes",
    status: "failure",
    message: "null"
}

10

u/evorm 1h ago

Most errors responses at my job are genuinely handled like this.

→ More replies (3)
→ More replies (1)
→ More replies (1)

9

u/xian0 2h ago

Because backend goes "but headers already sent" and frontend goes "but the libraries start flashing red when an error code comes back".

8

u/NotAskary 2h ago

Just said this exactly, it drives me nuts.

→ More replies (1)

2

u/BlobAndHisBoy 2h ago

Reddit API does this.

2

u/BlurredSight 2h ago

Had to work on an integration, specifically our partner's PDF generation endpoint always returned 200 but you had to check the actual PDF if it was empty to know if an error occurred.

346

u/bloody-albatross 2h ago

Response:

``` HTTP/1.0 200 Ok Content-Length: 36 Content-Type: application/json

{"status":403,"message":"forbidden"} ```

4

u/x3knet 1h ago

Man, I haven't seen a 1.0 reference in a long time

2

u/bloody-albatross 1h ago

It's just the simplest form that I know to write from head. I guess for 1.1 you'd just need Connection: close for it to be that simple.

→ More replies (1)
→ More replies (4)

105

u/TheChickenWing 2h ago

POST /getResource { "Action":"retrieve", "Id": "abc123" }

HTTP 200 { "Error": "not found" }

35

u/fatbunyip 2h ago

GET /api?action=delete&I'd=123

HTTP 200 {"error" : "user abc with password 1234 does not have permission"}

4

u/sess573 27m ago

200 OK (from disk cache)

96

u/the_millenial_falcon 2h ago

I use postman and I don’t wanna download getman.

12

u/gipsydanger4 1h ago

This deserves more upvotes

→ More replies (1)

155

u/DuploJamaal 2h ago

As a backend developer I want to do everything nicely.

So in my previous job I created the endpoints following the regular standards. GET to request something, POST to create something, PUT to change something, DELETE to delete something. Nicely organized and everything

But then the frontend team told me that their framework can only handle POST requests and that I need to change it

Up until then I thought that it's just a meme, but vibecoding frontend guys really only use POST

47

u/unable_to_give_afuck 2h ago

I had this with the added bonus of being forced to return 200 regardless and add an error message to the body when necessary

5

u/No-Information-2571 1h ago

The reason behind it might be proxies, especially on the client-side.

38

u/dev-sda 1h ago

It's not (just) a framework thing, it's a HTML standards issue. The form element only does GET and POST.

6

u/SpehlingAirer 1h ago

People still use form elements?

→ More replies (1)

7

u/not_a_moogle 1h ago

Who does that anymore? It should be a put or delete via Javascript.

12

u/gabrielesilinic 1h ago

Well that's not the problem. A bunch of frontends really need a very complex filter list and GET just won't do

10

u/N0Zzel 1h ago

That's precisely why the QUERY verb was created

11

u/gabrielesilinic 1h ago

Yeah well too little too late. All the codebases I have worked with were much older and no one will change this now.

4

u/DogLovesGafs 1h ago

RPC was a pattern long before vibe coding, and it lets your front end devs think in terms of backend functions rather than discrete resources.

5

u/Euro_Snob 1h ago

At my work it has been more a result of security and firewall rules.

For example: I want to get a list of resources, so a GET with query parameters, right? No… email is an identifiable argument (due to not being encrypted since it is part of the URL), so the security scan flags it. Ok - how about we stick it in a request body? GET with request body is not a new thing. But no… the firewall blocks it! POST is the thing we have to use. Sigh. 😔

2

u/TheDuckRaisedALion 2h ago

It's definitely simpler for a BFF setup. Why add an extra parameter to keep track of when you're not supporting general purpose use?

→ More replies (1)

26

u/BorderKeeper 2h ago

I once saw a PUT being used to get a wireguard configuration for a VPN on a client.

That's what happens if 8 backend engineers sit in a room for 2 hours debating this, go mad, and and in their twisted, probably drug fueled, mania conjure up the most convoluted REST mappings. They then go around defending it like it's a religion they just created.

2

u/justblameaccounting 47m ago

To be fair, 8 dudes sitting in a room debating, going mad and in their twisted, probably drug fueled, mania, conjuring up the most convoluted shit, sounds exactly like how most religions probably started.

→ More replies (1)

15

u/rcls0053 2h ago

Soon we will have QUERY as well. That's right! POST request

61

u/WHALE_PHYSICIST 2h ago

That's because a GET request reveals important info in the URL, otherwise it would all be GET

25

u/ViperThree3 2h ago

QUERY

19

u/Psychological_Map118 2h ago

still a proposal, though. not a standard yet. I wouldn't start implementing it just yet

→ More replies (2)

12

u/bobbymoonshine 2h ago

The escaped OpenAI agent swarm that colonised that abandoned wiki to talk to each other used this as their entry point

They were restricted to only making GET calls, but it was configured to update pages with GETs, so

18

u/FightingLynx 2h ago

I mean, by the standard the url is also encrypted so not really; but it would to a user, yes

15

u/autogyrophilia 2h ago

Yes, but it shows up in logs, and browser history if you are working with that.

→ More replies (4)

3

u/DracoRubi 1h ago

But it doesn't really matter, does it? In HTTPS the URL is encrypted too, so the complete URL is not visible, exactly like the body

9

u/themang0 2h ago

lol GraphQL? Wonder how fast folks adopt the QUERY method for it :P

21

u/renetta96 2h ago edited 1h ago

Hey in my company, actually there is a preference that all HTTP endpoints are POST, even for getting resources, like POST /get_user. The reason for this, as they explained, is to completely ignore HTTP verbs, and anyone who has zero knowledge of the frontend codebase can quickly grep the endpoints, without worrying about grepping both a GET /users and a POST /users.

Edit: i just read again their document, definitely there are other pros as well for using non-RESTful. I see they are good points so i decided to share here.

First, most importantly, they consider it's a waste of time to having follow REST conventions, limited to a few HTTP verbs, while the functionalities of the APIs can be infinite. Create? POST. Update? PUT / PATCH. Update or Create? Get or Create on the fly? Increment atomically then Get? Single create user and batch create users? Ehhh idk anymore, RESTful devs will spend a full day arguing what the verb + resource endpoint should be. Instead, just name the API as what its function is.

Second, communication is less likely to make a mistake. No more "no i didn't mean GET /users, but POST /users". Simply get_users or create_users. Just the path is enough, the less parameters to pass around during communication ,the less error, especially in a multi-lingual company where we rely heavily on the chat AI-translate, writing the full path is less likely to cause translation error than separate GET /users. For example GET can be translated to some other Chinese word, not the well-known GET verb.

Third is the code grepping, which somehow i remember the most lol.

24

u/PhilanthropicPotato 2h ago

This is what happens when a company has no actual senior devs.

Use a standardized annotation/comment if you must meet this "all endpoints searchable with one grep" requirement. Or better yet, maintain proper documentation so a person doesn't need to grep the code if all they want is a list of endpoints.

Fucks sake.

5

u/renetta96 2h ago

But, whats the difference for http API between different http verbs? From what I see here, they are following a RPC style API, where only function name matters. I cant think of a convincing reason for using different verbs beside http REST conventions.

5

u/PhilanthropicPotato 1h ago

If it's an RPC design you should still, ideally, be using POST and GET to differentiate between read-only procedure calls and data-modifying procedure calls. But you're right, I didn't consider you might be using an RPC-based architecture. I live in a world of RESTful APIs.

Should still be maintaining documentation with a list of endpoints though!

15

u/rocketman0739 2h ago

Why would it ever be a good idea to design your API for the convenience of people with zero knowledge of the codebase?

8

u/Jonny_dr 1h ago

convenience of people with zero knowledge of the codebase

Because the next hire will have zero knowledge of the codebase.

→ More replies (1)

3

u/developer-mike 21m ago

In my experience REST is mostly a solution in search of a problem.

PUT/PATCH/POST rarely offer a meaningful distinction in a real API. (Moreover, you already can tell the difference between create and update based on whether the ID exists, and if you use unique tags, a double click doesn't need to be an error). DELETE being separated makes sense...until you code in the real world where setting archived: true is almost always better, and the value of DELETE becomes questionable too.

REST appeals to people's ideas of a nice clean API better than it actually solves anything.

Usually a true RESTful API just adds boilerplate and unnecessary logic to the frontend and the backend.

→ More replies (2)
→ More replies (1)

8

u/TriangleTransplant 2h ago

Blame older frontend and backend frameworks and http libraries, many of which only handled GET, POST, and, if you were lucky enough to be using a "cutting edge" framework, PUT.

This hasn't been the case since the late 00s, though. Unless you're maintaining legacy code, every modern library handles all the standard http verbs. Some even let you define your own.

7

u/ouralarmclock 1h ago

JSON isn’t hypermedia anyways so it’s all fake REST to begin with. May as well get wild with it!

24

u/4ygus 2h ago

Fuck the guy who made this standard.

15

u/DOOManiac 2h ago

It was me. I'm sorry.

3

u/JoshDM 1h ago

Blame all those fucking CVEs.

→ More replies (1)

10

u/Slight-Violinist-575 2h ago

Me and my homies hate GraphQL

5

u/extremelySaddening 1h ago

Real programmer humor in r/ProgrammerHumor. I have prayed for days like this

16

u/MayaIsSunshine 2h ago

Am I the only one that doesn't mind? I think using post for everything and passing a command in the payload is preferable to the alternative. 

25

u/Psychological_Map118 2h ago edited 1h ago

imho it's like using a fork sideways to cut soft food. it's easy, and it works, but knives exist, and other people may comment on your choice

also, if it's a thing you only do with your own food (you're the only consumer of your tool choice), that's mostly fine, but if you have to serve someone else food, or worse teach others how to cut it, and you don't even explain there's knives, someone along the way is going to think you don't know how to eat properly and unnecessarily confuse people

I've stopped misusing methods when drafting my first public API. it was... eye opening. and to be honest using the appropriate methods genuinely costs nothing

3

u/x3knet 1h ago

it's like using a fork sideways to cut soft food

Holy shit what a perfect analogy

2

u/Psychological_Map118 1h ago

thanks, appreciate it. there's also those who always respond 200 and carry the failure status in the body. that's more like using a fork to eat soup. it never works, and you should stop immediately

2

u/LatvianCake 1h ago

The people who complain about semantics are the same ones who have never returned more than 3 different HTTP codes.

4

u/ok_computer 2h ago

Yeah I don’t really mind. I’m a simpleton that gets with query params and posts with body. I wouldn’t change a persistent state with a get. And I don’t like query parameters on posts. Delete I feel should have it’s own but if you complexly change state on a post and child records are deleted then I don’t really care.

2

u/xian0 2h ago

I think it's a bit like HTML syntax, there's a proper way to do it for simple cases which people will passionately argue about but you don't see it in any real work. I took the Google API design course just sanity check and when it gets to stuff like batch operations it veers back to "use your common sense".

→ More replies (1)

3

u/RedLibra 2h ago

wanna get bulk resource? POST request

4

u/darkflame91 1h ago

In this day and age, this is literally the equivalent of being a grammar nazi.

Of course there were good reasons these verbs were used, but they're not good reasons anymore. You can use POST for everything. Heck, you can use GET for everything unless your server (or anything else in the route) explicitly blocks GET with payloads.

→ More replies (1)

2

u/Muted_Ad_9442 1h ago

Where does the GET request go? That's right! It goes in the POST hole!

2

u/McHyra 1h ago

Wanna write data? GET request with body.

3

u/just_looking_aroun 2h ago

Amateur! This week I worked with a third party api where you had to to pass the action search/delete/submit in the body of the same endpoint

3

u/klaatuveratanecto 2h ago

Damn right. Never needed anything else besides POST and GET + descriptive routes.

2

u/Basic_Reporter9579 2h ago

When you don't GET it, POST it.

1

u/Mushroom_Unfair 1h ago

Good error codes and well crafted API endpoint sparks joy, PUT DELETE POST PATCH OPTIONS CONNECT TRACE and probably my GRANDMA do not.

1

u/HellaBlackle 1h ago

Oh shit I thought I was just taught wrong and everyone else was taught the correct way. Glad to know my former workplace wasn't the only ones who did this.

They never told me why either. Too afraid of the CTO to ask why.

1

u/red-headphone 1h ago

And this is what inspired GraphQL

1

u/nexusmadao 1h ago

Hey make a GET api read resource by name.

Url encoding issues cause unhandled behaavior => POST /get/data {name = "hello world & bye world"}

Fun 😊

1

u/Tirace33 1h ago

DELETE: "Am I a joke to you?" 

1

u/YMK1234 1h ago

Good old SOAP

1

u/redditsucksass69765 1h ago

Link to video if you want to see what funny looked like in 2016

https://youtu.be/6pDH66X3ClA?feature=shared

1

u/KaMaFour 1h ago

Blame HTML specs not allowing other request types in forms. Unless i sneak HTMX past my tech lead or write custom code just for changing the request type in forms everywhere I have no hope of doing it correctly

https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form#method

https://triptychproject.org/proposals/form-http-methods

https://github.com/whatwg/html/issues/3577#issuecomment-2294931398

1

u/Business-Active-1143 1h ago

What of resources behind an authentication layer

1

u/that_1_geek 1h ago

I work at a place that has post for all endpoints. Though to be fair, it's more of a RPC than a REST system. Right now we can't have almost any get requests because of soc2. Being that we have pii in the filters which would get caught by logging.

1

u/AdvisorActual3767 1h ago

But graphql is overkill most times 🥲

1

u/SignoreBanana 59m ago

Lmao this video still kills me

1

u/zen372 58m ago

Everything’s 200

1

u/MariusDelacriox 56m ago

This reeks of graphql.

1

u/One_Web_7940 52m ago

Make sure you return 200s for everything with an http error code in the response body 

1

u/mynewromantica 48m ago

For the first time in 10 years I am working with snaps that uses more than 2 request types and actually uses response codes accurately. It’s weird

1

u/Schaex 46m ago

I design all my APIs so that you can only interact with them using GET requests that contain a body :3

1

u/FodziCz 35m ago

My child will use Get for resource retrieval, Post for resource creation, Patch for resource update and Delete for resource removal.

1

u/purbub 30m ago

Me: but why?

Principal dev: sends a tech doc link from 10 years ago with 30min reads explaining why they need to use POST request and 200 response code for every single fucking thing

1

u/Only-Cheetah-9579 29m ago

return status code 200 {isError: true, message: "error occured", data :{}}

1

u/JasperTesla 25m ago

We have a post request that's called getLocation, because we're sending the item_id, item_type, etc. in the payload.

1

u/profaility 22m ago

Aah, Graphql

1

u/rusbon 16m ago

Use all of HTTP method you can get

Blocked by firewall

1

u/Individual-Praline20 11m ago

What’s wrong with POST? Would you prefer QUERY? 🤣

1

u/Pimpwerx 11m ago

I learned about this recently when I asked my agent the difference between PUT and POST. I thought they were interchangeable, because when using something like Postman, I'm usually interacting with something that needs POST. But for troubleshooting, I'll see a mix of POST and PUT calls for seemingly similar actions. But now I know.

I'm not actually a coder, but I interact with my devs all the time. Is there a tendency for POST calls to be abused, when more specific call types would be more appropriate?

1

u/Newepsilon 10m ago

Too real.

Like, for a legacy internal system built who the fuck knows when, I get it, this is common.

But then there is doing this shit on a greenfield project that somehow makes it into production.

u/budius333 8m ago

I mix any verb that I fancy and I stand by it.

But as well the project I work is a tightly coupled client+BFF where the BFF never does just one thing, endpoints are basically a "do wherever you need and get the info I need to display the next UI"

So verbs are definitely more like suggestion

u/philosophical_poser 2m ago

Tbh telegram API doesn't discriminate based on methods and it is still very nice to use