Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a method using REST

Tags:

rest

i have a rather general question: How to call a method in RESTful web service correctly?

The method is supposed to do only a transformation in the database and return nothing (so no GET?!). However I also send no values from the client (so no PUT/POST?!?).

So far I am using GET. Put i read thats not the proper way to do it...

Thanks in advance!

like image 910
pascalst Avatar asked Mar 11 '13 14:03

pascalst


2 Answers

REST stands for "REpresentational State Transfer". If you're not transferring state representing the thing you're working with (in one direction or the other), it's pretty much inherently not RESTful, and there's no correct way of doing it and still calling it REST.

If you want RPC, then do RPC. Just don't call it RESTful. :)

like image 197
cHao Avatar answered Dec 11 '22 17:12

cHao


The way you do it is through RPC. REST is good for state transfer, but not for triggering actions that have nothing to do with state transfer, such as operations that affect a large number of records. Most systems I've seen use REST for 99% of the work in supporting a UI, and RPC for that last 1% -- operations that do not involve state transfer, bulk update operations, that sort of thing. Your goal should be to express as much of the business logic as possible as reaction to application of state, reserving the corner cases for RPC.

like image 44
Todd Grigsby Avatar answered Dec 11 '22 17:12

Todd Grigsby