PDA

View Full Version : requestpayload in post is always query string



alanuofm
6 Aug 2012, 11:10 AM
Hey folks,

I'm having an issue with a proxy post request payload that is always posting as a query string instead of a json string.

Here is what my model currently looks like with a specified proxy.


Ext.define('HL.store.FacetListTreeStore', { extend: 'Ext.data.TreeStore',
model: 'HL.model.FacetsTreeModel',
autoLoad: true,
proxy: {
type: 'ajax',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Accept' : 'application/json, text/javascript, */*; q=0.01'
},
url: 'test.json',
reader: {
type: 'json',
root: 'ResultSet'
},
writer: {
type: 'json'
},
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
},
extraParams: {
recordOffset : "0",
rowsPerPage : "50"
}


}
});

The post request payload is always posting as

recordOffset=0&rowsPerPage=50

Any ideas on how to make it post as a json body such that it is {"recordOffset":0,"rowsPerPage":50}


Thanks,

Alan

alanuofm
6 Aug 2012, 5:19 PM
ok in case anyone is wondering here is the solution that I used


Ext.define('HL.store.FacetListTreeStore', { extend: 'Ext.data.TreeStore',
model: 'HL.model.FacetsTreeModel',
autoLoad: true,
proxy: {
type: 'ajax',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'Accept' : 'application/json, text/javascript'
},
url: 'test.json',
reader: {
type: 'json',
root: 'ResultSet'
},
writer: {
type: 'json'
},
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
},
extraParams: {
recordOffset : "0",
rowsPerPage : "50"
},
doRequest: function(operation, callback, scope){
var writer = this.getWriter();
var request = this.buildRequest(operation, callback, scope);


if (operation.allowWrite()) {
request = writer.write(request);
}


Ext.apply(request, {
headers : this.headers,
timeout : this.timeout,
scope : this,
callback : this.createRequestCallback(request, operation, callback, scope),
method : this.getMethod(request),
jsonData : this.extraParams,
disableCaching: false // explicitly set it to false, ServerProxy handles caching
});
Ext.Ajax.request(request);
return request;
}
}
});