So I have an ajax call that calls a controller action that fires off a package for execution that is separate from my main application which returns a result. That result (a success or failure) is what I want returned from that controller action and the ajax action is currently a GET request with the parameters for the package being sent with the request. Should this be a GET request to be 'RESTful', or should it be a POST request?
1 Answer
I would say it should be a POST. GET should have no other effects then to retrieve a representation of data. Here's what W3C says.
Use GET if:
- The interaction is more like a question (i.e., it is a safe operation such as a query, read operation, or lookup).
Use POST if:
- The interaction is more like an order, or
- The interaction changes the state of the resource in a way that the user would perceive (e.g., a subscription to a service), or
- The user be held accountable for the results of the interaction.
2 Comments
sea-rob
Good post. In support the HTML spec calls out post as the operation for "data processing" requests, which pretty much fits the bill here.
Julian Reschke
Well, what's relevant is the HTTP spec (and that's an IETF spec, not a W3C spec).