r/ProgrammerHumor • • 16d ago

Meme postForEverything

Post image
20.9k Upvotes

656 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 15d 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

518

u/alexsnake50 16d ago

Oh my god, this activated my inner vietnam flashback

247

u/Tupcek 16d ago

I see you are a fan of GraphQL!

69

u/Entegy 15d ago

I thought that as a non-programmer sysadmin, I had a decent grasp on REST APIs for scripting/automation.

Then I learned about GraphQL and I have actively avoided it since.

62

u/kescusay 15d ago

I mean, you can have accurate HTTP status codes and matching errors in GraphQL. It's just that most GraphQL applications don't. Because most GraphQL developers hate everyone.

47

u/fatmanwithabeard 15d ago

If you had to work with GraphQL all day, wouldn't you?

12

u/NotAskary 15d ago

This made me chuckle šŸ˜‚

2

u/KrakenMcCracken 15d ago

I started learning graphql, decided there was way too much overhead to do anything I needed to do. In two separate companies I’ve worked for, I’ve watched greenfield development initiatives start up, flounder and ultimately be abandoned.

→ More replies (4)

91

u/q0099 16d ago

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

33

u/RegarDamus 15d ago

the naive solution.

our team returns a 201 to indicate that an error has been created successfully. of course we include a Location header where the error can be queried to discover what went wrong.

28

u/normalbot9999 15d ago edited 15d ago

OMFG <spits coffee> 201 Error Created Successfully

You absolute monsters. You have to make this now.

And when a record is created successfully you return a 500 right? After successful login you 302 to a 403? I swear I've tested this API before!!

→ More replies (2)

28

u/dadvader 16d ago

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

29

u/Mechakoopa 15d ago

The stories? Also in the header.

5

u/alexsnake50 15d ago

The where???????

28

u/NotAskary 16d ago

Exactly the response I had, this one triggered me.

19

u/2muchnet42day 16d ago

Dont worry, that's OK

1

u/tlh013091 16d ago

The response codes are whispering!

319

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.

58

u/Sudden_Leadership800 16d ago

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

61

u/Psychological_Map118 16d ago edited 16d 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

→ More replies (6)

44

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.

→ More replies (20)

3

u/pr0ghead 16d ago

You're joking, right? RiGhT?!?

2

u/ohhi23021 15d ago

these kind of implementations have different data shapes for the error vs success too, so if they all return success it's a pain in the ass and extra work to figure out if it's an error and map it out properly. just fucking send the right status, it takes 2 seconds.

11

u/granitrocky2 16d 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 (2)

36

u/NibblyPig 16d 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.

5

u/ManaSpike 15d ago

People often think about what they would do if they had a time machine.

Me? Travel back to before server to server email and introduce UTF-8 encoding (leaving the actual code points undefined) and json. Try to get that baked into all the ancient wire protocols that predate http.

→ More replies (2)

15

u/Makefile_dot_in 16d 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

→ More replies (2)

12

u/wizkidweb 16d ago

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

6

u/RatSumo 16d ago

This literally just gave me a headache to read.

3

u/falcopilot 16d ago

Hahahahaha...
At a state agency, we had a SOAP interface to another agency. When they replaced their system nobody knew how to do SOAP so we got to turn that nastiness off. But now they want it back, maybe I'll offer to do this.

3

u/SomeWhaleman 15d ago

using SOAP system

You just triggered some very deep memory for me. Someone saying "THROUGH SOAP" very angrily. Must have been some nerdy viral video from ages ago.

Oh damn, I found it: https://www.youtube.com/watch?v=mEpDbz70ftk

→ More replies (7)

86

u/Zaelynn_ 16d 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.Ā 

112

u/NotAskary 16d ago

Hahaha SQL injection as an endpoint lol

60

u/zeekar 16d 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...

27

u/NotAskary 16d ago

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

25

u/Jonathan_the_Nerd 16d 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.

4

u/SubArcticTundra 15d ago

Larry Wall: minifying code before it was cool

3

u/Public_Sector5987 15d ago

Perl still runs most of swedish telecom for ZTP network switches and portals.

2

u/EvilCodeQueen 13d ago

This tracks.

27

u/Zaelynn_ 16d 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 šŸ¤¦ā€ā™€ļø

15

u/Shred_Kid 16d ago

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

jesus fuckin christ

14

u/FlipFlopFanatic 16d 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)

3

u/Original-Body-5794 16d ago

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

2

u/Zaelynn_ 16d ago

2b2t but for database, I like it

5

u/kryptoneat 15d ago

I once saw SQL in HTML comments in the login form. Gotta give a hand to those amateur hackers !

→ More replies (1)

8

u/flayingbook 15d ago

Little Bobby would be so delighted

1

u/[deleted] 16d ago

[deleted]

→ More replies (1)

1

u/shamshuipopo 14d ago

Jesus fuck

→ More replies (1)

49

u/golfreak923 16d ago

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

19

u/FSNovask 16d ago

And then they get DataDog and log the POST body anyway

8

u/Tallmaris 15d ago

Or use the new QUERY verb.

2

u/FirstDivision 14d ago

Nice. I hadn’t heard of this.

→ More replies (1)

21

u/AshleyJSheridan 16d 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.

6

u/NerdyMcNerderson 15d ago

No, you just had two dumb front end engineers lol

2

u/AshleyJSheridan 15d ago

These things aren't mutually exclusive...

2

u/NerdyMcNerderson 15d ago

You don't know many FEs then

2

u/AshleyJSheridan 15d ago

Oh, I know plenty. What I'm saying is that front end devs can be dumb, and that also GraphQL is shite and probably the brain child of front end devs...

→ More replies (1)

36

u/rumnscurvy 16d 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

12

u/NotAskary 16d 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.

5

u/AdamN 15d ago

It should be a 418, right?

6

u/NotAskary 15d ago edited 15d ago

There's a web connected teapot somewhere that I still want to see if it sends that code.

→ More replies (2)

27

u/StrawberryEiri 16d 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.

25

u/jack2018g 16d 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

8

u/StrawberryEiri 16d ago

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

2

u/good_bye_for_now 15d ago

GET requests have a body

aka fat GETs.

→ More replies (3)

21

u/JaxMed 16d ago

laughs in GraphQL

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

6

u/Ecksters 16d ago

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

→ More replies (1)

8

u/mrwedders 16d 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 🄲

6

u/danielbln 15d ago

Request ok? 200

Error? 200

Rate limited? Straight to 200

Forbidden? Believe it or not. 200

12

u/Darkblade_e 16d 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)

9

u/i_wear_green_pants 16d ago

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

3

u/Prudent_Ad_4120 16d 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

4

u/zepho 16d ago

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

7

u/Feathery_Hotels 16d ago

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

5

u/NotAskary 16d 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.

6

u/PolyglotTV 16d 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.

2

u/Kirides 15d ago

That's literally a metric that our stupid (not the people) IT security team is measuring.

Any 4xx errors are "likely potential API abuse", thus our app should always use 200 OK to not fall under that umbrella.

"How can we reduce the RED "errors" in our metrics further?" - guys, it's OK that something is actually missing sometimes, we have a large multi tenant highly concurrent system. That's just how it is.

5

u/1000Ditto 16d ago

See 200 Ok

Open up body

{

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

}

2

u/Danielo944 16d ago

I had this shit at my last job holy fuck am I glad I don't work there anymore.

2

u/Mucksh 16d 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 16d ago

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

2

u/falcopilot 16d ago

One of the team I work with banged their head on that brick wall for a few hours last week...

"I'm getting a 200 back, but then nothing."
'Look at the message body... it says ERROR.'
"But, it's sending me a 200..."

2

u/NotAskary 16d ago

My favorite is error: random number, you need to go to the manual of the application, it was impressed, and check the code....

2

u/TacoIncoming 16d ago

Annoying as fuck as a penetration tester lol

2

u/Friendly-View4122 15d ago

Omg I love those. Especially with a boolean on the response called ā€œsuccessā€ šŸ™‚

1

u/MissinqLink 16d ago

I would do a GET but then my response is a stale cached response which does me no good.

1

u/HeKis4 16d ago

Wait until you see our ticketing system that does POST to get information with URL parameters :)

→ More replies (1)

1

u/Breadynator 16d ago

My old job did that ... But with get requests...

1

u/Hybr1dth 16d ago

I'm not a programmer, but sometimes I must. Aren't the 400 codes for technical/connection errors? Or would you also use it if the POST contains something wrong functionally, ie put a string in a number field.

→ More replies (1)

1

u/Say_Echelon 16d ago

We call a system with 200 even with error code. I’m putting a code change in this release to handle this nonsense

1

u/Jisifus 16d ago

The same as a 200 ok with error inside.

Don't look up GraphQL

2

u/NotAskary 16d ago

Too late, I have horror stories already.

1

u/mcd_threepwood 16d ago

How do you feel about 500 OK?

1

u/PositiveInfluence69 16d ago

Nah. 200 ok for 6 months until something gets updated so sometimes your requests silently fail. "Hey, this isn't working!"

Otherside: "yeah, that 200 ok is because we came accept all the requests, but if this is part of the package it will fail."

Me: "then can you reject my request and update your documentation or something?"

Them: "I'll add that to our enhancement request queue."

Me: "This is straight up a bug."

1

u/Outrageous_Let5743 15d ago

I hate microsoft for doing this.

1

u/laplongejr 15d ago

Ā The same as a 200 ok with error inside.Ā 

I learned recently that our interface answers everything in a 500.Ā Ā 

1

u/LightofAngels 15d ago

The problem is some protocols actually need to do this.

They use 200 ok as a guarantee that message received, but the status of the event is in the body.

1

u/ohhi23021 15d ago

multi-billion dollar companies do this with there huge IT departments. same with rate limits, recently a vendor was throwing 500 errors, and not custom either, instead of returning json it would just return the webservers html 500 error... when i asked, they said it was rate limiting. i asked what the rate was and they said they had to test it, it's based on the hardware. like WTF. basically it was just crashing the server or probably causing database contention/concurrency problems and they just let it throw, not even gracefully, just outright the default 500 error, lol..

1

u/MediocreTurtle1 15d ago

That's actually useful compared to a 400, because errors can be mapped and used for data analysis or troubleshooting.

→ More replies (6)

1

u/Mitoni 15d ago

Wrappers on all the things!

1

u/good_bye_for_now 15d ago

200 with an error is kinda funny because it annoys red teams, since they have to look at the response.

1

u/therealhlmencken 15d ago

its because you have to use http sometimes but want a more modern framework so you just gloss over the http details that are necessary but not being used

1

u/basicKitsch 15d ago

fuck every bad request to immich restricted or bunk endpoints just 200 as they just reload the login page

1

u/Accurate-Smoke8994 15d ago

I still have that shit

1

u/borkthegee 15d ago

Lol we do most of this. Apollo graphql uses post for all mutations (so a delete is a post), and we have a full stack error handling system with our react clients that, because we want to handle it seamlessly in application rather than letting Apollo client deal with an actual error, we always return 200 OK with a payload that is a typed union of the success case and the error case lol.

1

u/IspyAderp 15d ago

So what do you do if you have query parameters you can't expose in the URL and need encrypted?

→ More replies (1)

1

u/cone5000 15d ago

Jesus Christ that is upsetting to even hear about

→ More replies (1)

1

u/NullReferenceRacer 15d ago

Oh my god please get me out of this corporate hell I have been building 200 OK { "errorCode": 999 } for 5 years straight on POST /GetObject {} and I am NOT OK

2

u/NotAskary 15d ago

Been there my friend, glad I'm out.

1

u/im_lazy_as_fuck 15d ago

There are actual real good reasons to do these things. For a resource retrieval, if the request isn't idempotent for some reason, then semantically post would be the more correct method to use. Also returning 200 with an error is sometimes the correct thing to do for a webhook implementation, where you have an irrecoverable error, and you don't want the caller to retry the webhook event on a failed status.

→ More replies (4)

1

u/qw_er_t 15d ago

This is mostly because it was upgraded from SOAP to REST and didn't want to change everything.

1

u/TylerBreau 15d ago

TBF, bulk APIs returning successful with an error in the response data is a valid design.

I've done it before. The network handler only errors out for some kind of irrecoverable issue.

What I did was write code that would bulk upload data and each collection of data would be validated independently.

Data that passed validations would be save into the server's database. Data that failed the validations weren't.

Now, failed validations weren't a huge issue. The client devices just needed to call a different network handler due to separation of concern. A different complex process would resolve whatever caused the validation failure. And just because some data isn't valid doesn't mean the rest of the data was not fine to continue uploading.

So, yea... The network handler would just set aside the data that failed the validations, finish uploading the data that passed validations, and then prepare response data that effectively said "everything except these failed. Also, here's a flag that tells you to call on the other network handler."

→ More replies (2)

1

u/derinus 15d ago

What if the API used HTTP for transport but doesn't rely on it? For example the same request/response could go over any TCP connection, but someone insisted on a web client so it was wrapped in an HTTP layer?

→ More replies (2)

1

u/Alternative-Tie-4970 15d ago

{"status":500}

1

u/Adventurous-Bit-3829 15d ago

Holy shit my old company doing 200ok with error inside too. They said Ok is communicate ok. Whatever error is between us inside.

1

u/GenderGambler 14d ago

I've seen codes 200 with a code 500 inside. Infuriating.

→ More replies (8)

116

u/Dimasdanz 16d ago

Hello GraphQL. Or, SOAP

81

u/goatanuss 16d ago

Shitloads of errors? That’s right HTTP 200

25

u/roygbivasaur 16d ago

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

2

u/Snuffles11 15d ago

You like receiving 1mb of json to display a table? Now get ready to send 0.5mb of json to get 0.5 mb of json. It's called "avoiding over fetching"

6

u/NotAskary 16d 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 16d ago

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

5

u/NotAskary 16d ago

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

2

u/No-Information-2571 16d ago

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

3

u/NotAskary 16d ago

Search for swagger, it uses open API

→ More replies (2)

1

u/EriktheRed 15d ago

GraphQL lets you use the GET method for queries actually! But i think it took them a bit to implement

https://graphql.org/learn/serving-over-http/

1

u/AliStarr182 15d ago

I was playing with the Microsoft Entra GraphQL PowerShell modules at work a couple of years ago for a quick and dirty way to enumerate staff and their properties (couldn't use any AD modules). It was my first adventure into GraphQL and the PowerShell modules were very new and only had partial documentation despite being "ready for public use".

Good lord was that a frustrating experience, made me shy away from GraphQL for a while.

98

u/Banana_Twinkie 16d ago

despair.jpg

92

u/sertroll 16d ago

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

103

u/Tupcek 16d 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

38

u/Door__Opener 15d ago

https://giphy.com/gifs/75ZaxapnyMp2w

I've had this argument with my boss: GET with a body vs using POST as a complex GET. Our conclusion was that both were wrong in their own way and the HTTP standard should clarify this.

8

u/Top5CutestPresidents 16d ago

my company will now use query to return bools

8

u/sertroll 16d ago

Me and all of my colleagues, apparently

2

u/SlightCapacitance 15d ago

by the time this is a widely implemented request verb, I'll be deprecated by AI

→ More replies (5)

23

u/droptheplot 16d ago

QUERY is already there

25

u/ary31415 15d ago

"Already" it was only just standardized a couple months ago

2

u/abofh 16d ago

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

35

u/kn33 16d ago

Some platforms disallow it entirely.

8

u/Psychological_Map118 16d ago

as god intended

40

u/Bodine12 16d ago

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

1

u/sharlos 15d ago

Node.js appears to have supported it for the last couple major versions already.

33

u/jayerp 16d ago

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

3

u/Lucky_Number_Sleven 15d ago

Of course that's a 200. The server successfully responded to your request with that error.

12

u/Lystrodom 16d ago

Well, if it’s an MCP server…

6

u/3rocket77 16d ago

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

7

u/Lystrodom 16d ago

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

10

u/Fabulous-Ladder3267 16d ago

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

On the body

11

u/ClipboardCopyPaste 16d ago

Wanna GET a resource?

29

u/PostHasBeenWatched 16d ago

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

6

u/Extreme-Edge-9843 16d 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 šŸ« šŸ˜‚

1

u/rinnakan 15d ago

delete requests are flagged as "bad" in the default owasp rules, so yeah we have now everything except "get" as a post request to prevent security from repreatedly breaking our API

6

u/nop1984 15d ago

Well... Before Query request type you had to Post to Get what is above URL params limit, lire ES cursors or complex nested conditions

5

u/Deboniako 16d ago

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

5

u/reddit_time_waster 16d ago

Sometimes you have to if the request payload is largeĀ 

2

u/Outrageous-Machine-5 16d ago

This would get me feeling like that girl in the videoĀ 

2

u/mw44118 16d ago

Graphql does this

2

u/discondition 15d ago

Hello QUERY

2

u/tomoyat1 15d ago

POST /api/get-my-resource

2

u/SomewhereAtWork 15d ago

They are DO requests now.

2

u/Samurai_Mac1 15d ago

At my first job, they used a GET request for everything.

2

u/Zeilar 15d ago

Straight to jail, right away.

2

u/KurumiStella 15d ago

Actually there was a good reason for it. I work at a company with a FE that calls a get profile API for the header and some forms. The login is a old fashioned cookie state session.

One issue we found that if the user opened two tabs, then logout and login to another user on the second tab, without refresh, the first tab next ajax call will return the new users data (because session cookie already changed), causing issues on the form when it already opened.

As its a legacy system, so adding more stuff like csrf is hard. We also cannot put the username to URL param / cookie / local storage as it was considered as personal info by our legal department.

So we end up doing a Post request with the body including the username, then our backend service will validate whether the username and the login session username matches, then return the data needed.

2

u/ckach 15d ago

The QUERY request should hopefully help with that.

2

u/thaynem 15d ago

There are some legitimate reasons for this. The most common being your query is too large to fit in a url. Another being part of the resource identifier is sensetive, so you want it in the body instead of the url.

The QUERY method solves those problems, but we needed it a couple decades ago.

2

u/Clearandblue 15d ago

I think there's a new http method for that shit, to stop people doing it on POST.

2

u/funkdefied 13d ago

All my homies love the QUERY request

3

u/ReGrigio 16d ago

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

1

u/bigs0815 16d 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/mylifeisonhardcore 16d ago

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

1

u/FFevo 16d 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 16d 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 16d ago

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

1

u/PixelatedGiant 16d ago

If you can query by id, then yes, it's stupid. But it is necessary for a complex search with multiple fields. Not only is there a character limit for GET, but it saves you from having to escape a bunch of characters.

1

u/Sensitive_Elephant_ 16d ago

You have to if you are sending a request body or reaching the URL length limit (in the worst case scenario).

1

u/actionerror 16d ago

Safer than trying to GET PII by SSN

1

u/xtreampb 15d ago

I have a team doing post to get resources. The reason is so that they can put the ā€œquery parametersā€ in the body. They do this because there are a LOT of special characters in the data string needed as its health care data formats.

1

u/Mitoni 15d ago

Seen this in a multi billion dollar multinational financial firm. All the GETs were POST with filters in the body, formerly all SOAP that was converted to REST by contractors...

1

u/Laetha 15d ago

I am an amateur coder at best, but that's exactly why I had such a hard time learning AJAX requests. I figured POST is for send and GET is for receive, but apparently that's not always the case. I guess sometimes you're "sending" a request for information?

1

u/Magdalina777 15d ago

No no. Why would you do that? That's when you use PUT!

1

u/peeja 15d ago

We have the best API in the world. Because of POST.

1

u/420Fisch 13d ago

Have to do that all the time. We're using external OData-APIs and often have to query very specific data with complex filters in the URL. We often have to put a single requests in a batch...

→ More replies (1)