Adding parameters to rest GET request
get, post, rest
Solution
To get more than one item, I would do something like this:
GET http://example.com/items/1_2_3_4
Where 1, 2, 3, 4 are the item IDs. To get just one item, you would do:
GET http://example.com/items/1
For the sort order, I would make this a query parameter. In general, a REST URL should point to a resource or several resources. Anything extra like sort order, resource format, etc. should be a query parameter:
GET http://example.com/items/1_2_3?order=by_name
Problem
I have an application running with AS2/PHP. The AS2 communicate with PHP scripts via $_POST array of data, this array contains data like sessionkey, userID, and some database filtering (sql limit, order by etc.) An iOS version of the application is planned, and I am trying to figure out the best way to use the existing server side code and rewrite only the graphics. The problem is that I need a lot of data, data which ideally should be sent via $_POST array into a GET http request (sorry if I am not clear, don't hesitate to ask me questions). I've read this post Understanding REST: Verbs, error codes, and authentication which made me understand better how REST should be working, but I need more data sent to server. For example, let's say I'd like to retrieve a collection of items, the request would be something like: ``` GET http://xxx/rest/item ``` But how do I tell the server that i'd like to retrieve only X elements from the collection, or even which sort order i'd like ? Thanks previously for your answers EDIT: @laurent, here an example of a script POST parameters received: ``` // COMMON PARAMETERS (each script) $idPROF = Utils_Mv::getVariablePOST('idPROF'); $idVISITE = Utils_Mv::getVariablePOST('idVISITE'); $typeConnexion = Utils_Mv::getVariablePOST('typeConnexion'); $typeSupport = Utils_Mv::getVariablePOST('typeSupport'); $cleSession = Utils_Mv::getVariablePOST('cleSession'); $idCLIENT = Utils_Mv::getVariablePOST('idCLIENT'); $idCONTEXTE = Utils_Mv::getVariablePOST('idCONTEXTE'); // SCRIPT-SPECIFIC PARAMETERS $idSUIVI = (int) Utils_Mv::getVariablePOST('idSUIVI'); $nbPrescription = (int) Utils_Mv::getVariablePOST('nbPrescription'); $indiceDebut = (int) Utils_Mv::getVariablePOST('indiceDebut'); $critereTri = Utils_Mv::getVariablePOST('critereTri'); $isTriInverse = Utils_Mv::boolval(Utils_Mv::getVariablePOST('isTriInverse')); $chaineFiltres = Utils_Mv::getVariablePOST('chaineFiltres'); ``` You would pass the common parameters as get parameters on GET request ? (and POST for PUT/POST)