View Full Version : Filter too long for GET, pass in POST?

11 Apr 2012, 2:03 PM
So basically we have infinite scrolling and would like to do some filtering. The issue is that we want the reader to pass in a filter that ends up being TOO large for a GET but we are having issues passing it as a POST and having our Rest recognize it. What is being passed in the body of the POST is like this:


which is obviously how it was meant to be encoded for a GET url rather than a POST JSON object.

I was expecting (or hoping) to pass it like this:
{ group: 'Device',
page: 1,
start: 0.
limit: 100.

Any advice on this?

11 Apr 2012, 5:33 PM
You could use an approach like:

var myobject = [];
myobject.push({ group: 'Device' });

method: 'POST',
url: 'search.php',
params : {
data: Ext.encode(myobject)
success: function() {
// observable catches errors
failure: function() {


11 Apr 2012, 6:15 PM
Will this work through a proxy in a model?

Right now we have a model setup for create/update/destroy/read

Ext.define('Device', {
extend: 'Ext.data.Model',

idProperty: 'Id',

fields: [
{ name: 'Id', type: 'int', mapping: 'Id' },
{ name: 'DeviceId', type: 'int', mapping: 'DeviceId' },
plus other fields

proxy: {
type: 'rest',
reader: {
type: 'json',
root: 'Data',
totalProperty: 'TotalCount'

Ideally we want to change the way the read call works (default GET) so we can maintain functionality with the rest plus the grid this feeds is infinite scrolling so it would need to trigger the load call based on paging. I don't know how to do that using just Ext.ajax querying (since I normally use that call as a one time shot thing).

Thanks for the feedback.

11 Apr 2012, 11:10 PM
You have to adjust the actionMethods of your proxy, so the rest proxy uses a POST for read functionality:

{read: "POST"}

Then you have to pass in the params before sending. I actually pass a jsonData attribute to it before. I override my store, so the save function deals with a given attribute "sendWithPost" and then takes an additional parameter as the jsonData attribute before sending it to the server. The jsonData is better, if you already uses some JSON deserialization thing on the server.. otherwise use params instead.

12 Apr 2012, 5:15 AM
Could you be more specific in how I incorporate the jsonData aspect with the read call of the proxy?

As I said in my first post, I managed to get the read action to make a post, the issue is the body of the post is just the params being encoded as if they were part of the url, not as JSON objects or anything like that. That's where I'm having a hiccup.

It's not that I can't do posts, or that I can't send JSON objects to the server (using Ext.Aja.request) it's incorporating that into the read action of a proxy that is the issue.

12 Apr 2012, 6:43 AM
So i was playing with the buildRequest function of the proxy and observing things through Fiddler and noticed that really the issue I am having is that the content-type of the POST is still Content-Type: application/x-www-form-urlencoded; charset=UTF-8 instead of Content-type: application/json.

This appears to be the last part of the puzzle for me. Anyone know where I need to change that? It does not appear to be a property of the proxy or reader.

12 Apr 2012, 7:42 AM
Apologize for the multi posting, didn't see an edit post option.

headers field in proxy is what I was looking for to change content-type. Issue I was having before was result of having headers section defined twice so the second one was overwriting the first (love team projects lol).


And of course right after I submit this the Edit Post appears. :/