I am new to restler3.0. I am trying to run sample examples given in the public folder. I got strucked when trying to run the routing example. I am trying to call the api/method/{param1}, in this method one more param is there and that is in array format. I dont know how to pass array values to this param2. I tried some of the ways but all has been failed. Someone can explain me regarding how to pass array to this method. I am using cygwin terminal to execute curl commands
Asked
Active
Viewed 511 times
1 Answers
0
If you mean this one (or similar):
* Auto routed method which maps to POST api/method/{param1}
*
* @param int $param1 map to url
* @param array $param2 map to request body
* @param string $param3 map to query string
*
* @return string
*/
public function postMethod($param1, array $param2, $param3 = 'optional')
{
return 'you have called Api::postMethod()';
}
then $param2 maps to the request body. So if you are POSTing, $param2 would be the array of POST variables you are submitting.
I'm not familiar with curl via cygwin terminal, but I think it would be something like this?
curl -X POST http://myserver/api/method/1 -d firstname=Joe -d lastname=Smith
which would send 1
into $param1 and firstname=Joe&lastname=Smith
into $param2.

Lys777
- 426
- 1
- 3
- 11