user10058046
user10058046

Reputation:

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?

Upvotes: 0

Views: 73

Answers (2)

Miguel Cabrera
Miguel Cabrera

Reputation: 191

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.

Upvotes: 1

GET - It perform when you first time enter to page

POST - It perform when you make some actions(for example you will change data) on the page and after that you reload it

Upvotes: 0

Related Questions