Search code examples
httppostasp.net-web-apiget

Should this request be GET or POST?


My API accepts 2 parameters, product and quantity, and it returns a price.

At the moment this is a 'GET' request, which makes sense. But there are now new requirements to log every price that is returned in an audit table. This now feels like a POST?

Question

What is/where can I find the criteria for determining whether a request should be made as GET or POST?


Solution

  • Well, this is some subjective, but I think I'll let the API as GET request. You're not creating or updating the price (your main entity), auditing it's just a side effect.

    Also you can think, as a developer who doesn't know about the auditing process and consumes your API, getting information using POST can be weird.