'Which HTTP request method doesn't alter the state of the server?

Having a hard time finding info on request methods that don't alter the server state.

PUT

PATCH

POST

GET

My assumption would be GET solely do to the fact that it's not introducing any new information to the server.



Solution 1:[1]

This is a convention, not an enforced rule. When designing REST interfaces, people usually use GET for operations that don't alter the underlying resources' state, and PUT/PATCH/POST/DELETE for the ones that do. That said, it's nothing more than a convention; I've seen apps from major vendors violate it. The thing with conventions that no one is strictly adhering to, the public infrastructure won't penalize you for breaking it. That said, there are some optimizations that adhering to the convention might enable.

Also, this is only for the REST-style interfaces. In the SOAP protocol, for example, everything is implemented via POST.

Solution 2:[2]

It is the responsibility of the application on the server to implement the safe semantic correctly, the webserver itself, being Apache, Nginx or IIS, can't enforce it by itself. In particular, an application should not allow GET requests to alter its state.

A call to a safe method, not changing the state for the server:

GET /pageX.html HTTP/1.1

A call to a non-safe method, that may change the state of the server:

POST /pageX.html HTTP/1.1

A call to an idempotent but non-safe method:

DELETE /idX/delete HTTP/1.1

GET is the right choice in those ones.

Please refer to this: https://developer.mozilla.org/en-US/docs/Glossary/safe

Solution 3:[3]

IANA has a list of standard HTTP Methods. The methods that are 'Safe' should not alter the server state. Methods that are not 'Safe', might.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 apollo
Solution 3 Evert