jasonhinkle / phreeze

Phreeze Framework for PHP
http://phreeze.com/
GNU Lesser General Public License v2.1
377 stars 166 forks source link

The request body does not contain valid JSON #166

Open bmborges opened 10 years ago

bmborges commented 10 years ago

when I insert or update the record returns this warning

{"success":false,"message":"The request body does not contain valid JSON","errors":[],"stackTrace":["0 [internal function]: CidadeController->Update()","1 E:\Domains\redelist.com.br\wwwroot\admin\libs\verysimple\Phreeze\Dispatcher.php(161): call_user_func(Array)","2 E:\Domains\redelist.com.br\wwwroot\admin\index.php(28): Dispatcher::Dispatch(Object(Phreezer), Object(SavantRenderEngine), '', NULL, Object(GenericRouter))","3 {main}"]}

whats happening ?

nick-barnes commented 9 years ago

I'm having the same problem. I can delete a record but adding/updating a record for certain tables returns the error:

The request body does not contain valid JSON

Any ideas?

jasonhinkle commented 9 years ago

Hmm can you check the network debug tab and see what's being sent in the request body?

It's possible also that your server is not liking PUT requests - that can happen sometimes. If that's the case, there's a couple of settings that you can try which will be located in model.js - they look like this:

Backbone.emulateHTTP = false;
Backbone.emulateJSON = false;

You can try setting the HTTP emulation to true first and see if that makes a difference.

nick-barnes commented 9 years ago

Changing HTTP emulation to true hasn't worked. There is an issue with the PUT request. Adding and deleting records is successful. Updating is throwing the error below:

PUT http://eiadb.com/eiadb/api/contact/1 401 (Authorization Required) p.support.ajax.p.ajaxTransport.c.send @ jquery-1.8.2.min.js:2 p.extend.ajax @ jquery-1.8.2.min.js:2 a.ajax @ backbone-min.js:1 a.sync @ backbone-min.js:1 h.extend.sync @ backbone-min.js:1 h.extend.save @ backbone-min.js:1 page.updateModel @ contacts.js:265 (anonymous function) @ contacts.js:51 p.event.dispatch @ jquery-1.8.2.min.js:2 p.event.add.g.handle.h @ jquery-1.8.2.min.js:2

Thanks for your help with this. You can see the site my test site here http://eiadb.com/eiadb If you want to recreate the error then feel free to add/update/delete a record. The database contains dummy data.