0

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
  • If it were a long-running process, you might use POST to start a distributed process, and GET to get the state of the process as it runs. Commented Jul 19, 2013 at 22:31

1 Answer 1

2

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.
Sign up to request clarification or add additional context in comments.

2 Comments

Good post. In support the HTML spec calls out post as the operation for "data processing" requests, which pretty much fits the bill here.
Well, what's relevant is the HTTP spec (and that's an IETF spec, not a W3C spec).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.