The utility of HTTP GET method

Working with the web for a considerable time. I've came across the following though: "You don't do an GET anymore. I'ts 'Ugly' to do so because it generates an ugly URL". That came especially from some juniors devs that I've contacted in recent years.

But to tell the true. It is a little bit of ugly to pass a lot of parameters vi the get attribute to url. But it has a good and meaningful propose. It is made to... wait for it... to get the data from somewhere.

As it is pointed by some authors in the REST/Hypermedia/Webservice literature. When you perform the an HTTP request using the GET parameter at the header. You must not interfere with the universe that the service you are fetching the data from lives in. That's why when you enter some news sites you are fetching the content with it.

The Get method must be safe. And of course it must also be idempotent. Which means it must not cause any side effects to the system. It only exists to fetch the data by a meaning url. For example the url /books says something. It says that it will fetch some books. But let's says I'm developing some library system. And of course I need to apply some filters to the /books url. In that case It's really ok to pass parameters at the url like /books?genre=fiction. It has a meaning that I want to fetch some books of my system And wanna to apply the filter that says, I wanna books with the genre fiction. It's not so ugly like the guy I quoted at the beginning of my post, because it has some meaning.

But let's say That I wanna to fetch the cover of a specific book. In that case you should use the cover parameter in the URL and not in the segment expansion. Which means that your url can be /books/13/cover. That means that I will fetch the cover of the book with the id 13. The expansion path must be used to represent some kind of segment of the resource. In that case. the cover of an specific book.