Thanks for this great plug-in!! I've been messing around with it for a few hours tonight and I am very impressed.
There is one thing that I could not seem to figure out. I am trying to save a record by posting JSON data to my controller. It works fine when posting with XML data - but not JSON data.
To get the post with JSON to work I had to make a few changes and I would like to get your input as to if I am missing something.
I am using cakephp 1.3.8
I made the following modifications to get posting JSON data to save and create a record.
I had to comment out the header logic on lines 644-662
/*
switch ($ext) {
case 'json':
// text/javascript
// application/json
if ($this->_settings['debug'] < 3) {
header('Content-Type: text/javascript');
$this->Controller->RequestHandler->setContent('json', 'text/javascript');
$this->Controller->RequestHandler->respondAs('json');
}
break;
case 'xml':
if ($this->_settings['debug'] < 3) {
header('Content-Type: text/xml');
$this->Controller->RequestHandler->setContent('xml', 'text/xml');
$this->Controller->RequestHandler->respondAs('xml');
}
break;
}
*/
I did this in order for me to use the
$this->RequestHandler->requestedWith('json')
method in my controller's before filter to be able to decode the posted JSON and put it into $this->data:
{"data":
{"Chart" :
{
"name": "Wages Plunged",
"type": "b",
"description": "While job losses were less severe than in recessions past, private-sector earnings declined by 10.1% between 2008 and 2009, the largests year-over-year decrease since at least 1991."
}
}
}
This is working now as I expect it to with these changes, however I could not get it to work "out of the box" like the xml did. Any thoughts?
Hi.
Thanks for this great plug-in!! I've been messing around with it for a few hours tonight and I am very impressed.
There is one thing that I could not seem to figure out. I am trying to save a record by posting JSON data to my controller. It works fine when posting with XML data - but not JSON data.
To get the post with JSON to work I had to make a few changes and I would like to get your input as to if I am missing something.
I am using cakephp 1.3.8
I made the following modifications to get posting JSON data to save and create a record.
I had to comment out the header logic on lines 644-662
I did this in order for me to use the
method in my controller's before filter to be able to decode the posted JSON and put it into $this->data:
and because it was not being loaded in $postData in the RESTComponent it wasn't being saved to the logs table data_in column so I changed line 824 to:
Here is some sample data I am sending in:
This is working now as I expect it to with these changes, however I could not get it to work "out of the box" like the xml did. Any thoughts?
Thank you!