SmartStoreNET icon indicating copy to clipboard operation
SmartStoreNET copied to clipboard

HTTP POST method used for querying data?

Open AlexanderDerck opened this issue 8 years ago • 5 comments

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?

AlexanderDerck avatar Oct 03 '18 14:10 AlexanderDerck

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...

mgesing avatar Oct 03 '18 16:10 mgesing

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?

AlexanderDerck avatar Oct 03 '18 19:10 AlexanderDerck

I don't know about any. It's OData related. GET is not possible here.

mgesing avatar Oct 03 '18 21:10 mgesing

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.

AlexanderDerck avatar Oct 03 '18 21:10 AlexanderDerck

No, GET is not possible. You get an HTTP error when you try to reach the API endpoint.

mgesing avatar Oct 04 '18 07:10 mgesing