HTTP POST method used for querying data?
I am reading the documentation for products, and came across the following part:
Get final price of product with ID 211 1 | POST http://localhost:1260/odata/v1/Products(211)/FinalPrice
Note the post method. There is a second action, LowestPrice, which returns the lowest possible price for a product.
On another page the same thing:
The endpoint for searching products is Search. It's an OData action and only accessible through the POST method. 1 | POST http://localhost:1260/odata/v1/Products/Search?q=notebook
Is there any particular reason GET is not used for some of the querying operations?
These are OData actions. They can only be invoked by POST.
Actions have side-effects on the server. For this reason, they are invoked using HTTP POST requests...
These are OData actions. They can only be invoked by POST.
Actions have side-effects on the server. For this reason, they are invoked using HTTP POST requests...
That's what's getting me confused. Does querying the data (getting finalprice & searching all products like 'notebook') actually invoke a side effect?
I don't know about any. It's OData related. GET is not possible here.
I don't know, https://www.odata.org/documentation/odata-version-2-0/operations/ point 2.13 sounds like GET is possible to me:
Clients may invoke a Service Operation by issuing an HTTP GET or POST request against their URI.
GET /odata/odata.svc/GetProductsByRating?rating=4 HTTP/1.1 Host: services.odata.org DataServiceVersion: 1.0 MaxDataServiceVersion: 2.0
Maybe I should look more into OData though, there might be something I'm missing.
No, GET is not possible. You get an HTTP error when you try to reach the API endpoint.