PDA

View Full Version : 400 : Bad Request error



Mariya Baby
21 Jul 2017, 4:53 AM
Hi all,

I have error while doing the POST using the load of ext.js store. Can anyone help me?

This is the store.
Ext.define('store.root1', {


extend: 'Ext.data.Store',
model: 'model.root1',
proxy: {
type: 'ajax',
url: '/module/alert/',
reader: {
type: 'json',
root: 'root1'
},
writer: {
type: 'json'//,
//root: 'root1'
},
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Accept': 'application/json'
},
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
},
paramsAsJson:true
},


sorters: [
{
property: 'name',
direction: 'ASC'
}
]


});




loadData : function () {

this.testorgstore = Ext.create('store.root1');
//params = JSON.parse(JSON.stringify(params));
this.testorgstore.load({
params : {
jsonData :Ext.encode(JSON.stringify(params))
}
});
}



after this call, i'm getting a 400: bad request error.

Gary Schlosberg
21 Jul 2017, 6:07 AM
Are you able to view the JSON being sent to the server?

Mariya Baby
21 Jul 2017, 6:29 AM
In the request payload , i can seen the json being sent but it has some garbage values..

Gary Schlosberg
24 Jul 2017, 3:14 PM
So certain characters are messing it up or the values are incorrect?

Mariya Baby
24 Jul 2017, 8:31 PM
Hi guys. Thank you so much for all the replies and help. It was actually because of the json structure. The json structure that they were expecting at the backend was not being sent from the front end. That's why the bad request issue.Thanks!

Gary Schlosberg
25 Jul 2017, 6:54 AM
Sounds about right. Glad to hear it's working now, and thanks for posting a follow-up!