Reputation:
I am using a System.Web.Http.ApiController
in my application. One of the functions I need is to have an admin screen with a button on it that will initiate some method on the controller to move data from one table to another. The action should complete within a few seconds. There need be no parameter sent to the action and I assume that I can do this with a normal HTTP call to a method on the WebAPI controller.
However what type of call should this be? GET, POST, PUT ? None of these really seem to fit so I would appreciate some advice.
Upvotes: 0
Views: 130
Reputation: 23214
Given that POST in REST can be interpreted as "process" , I would go for POST. Also, POST is not idempotent so you can do pretty much whatever you want with it.
Upvotes: 0
Reputation: 142202
If you are "moving" data then the operation is "unsafe" and "non-idempotent" therefore POST correctly describes those semantics.
Upvotes: 3
Reputation: 851
I would go for a POST or PUT - it doesn't really matter.
Wait, what?
Honestly, if it is to kick off some internal admin system function rather than to add an entity to a truly RESTful API then I would advise you to avoid getting caught up in HTTP semantics, as you aren't doing REST.
You don't even need to use Web Api, you could just have the form on the page post back to a standard action method on your MVC controller.
Upvotes: 1
Reputation: 151672
Given REST is based on resource access, neither GET, POST or PUT apply. You're retrieving nor sending resources. You're, frankly, calling a Remote Procedure Call.
You can however expose this RPC as a resource, though one that only allows one method. It's up to you to name and implement this. I'd say you POST
to /Admin/BeginCopyingData/
.
Upvotes: 1