I write simple function to list data for web service request.
I try to access data in my controller like this.
public function action_ListData() {
var_dump($this->request->post("jsondata"));
die();
}
This is my json.
{
"jsondata":
{
"id" : "1234"
}
}
I can't access json data. It prints empty array. how can I access the data? Please advice. Thanks in advance.
request->post()
is for getting form encoded data likejsondata={"id":"1234"}
but your entire request body is a JSON payload, so you should use this: