1

I'd like to perform a RESTful get request like

"/commments/123" <br/>

but it always request addtional parameters like this

:<br/>
" _dc=1337095865783&page=1&start=0&limit=25" <br/>

Please tell me how to convert the addtional parameters to RESTful request

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
Alex Chan
  • 1,116
  • 3
  • 15
  • 33

1 Answers1

4

You can remove extra parameters being added by Sencha automatically by setting any of the xxxParam options to false on the proxy object (limitParam, enablePagingParams, startParam, etc) and also disable the _dc cache querystring with noCache:

proxy: {
    type: 'rest',
    url: '/comments',
    noCache: false,
    limitParam: false,
    enablePagingParams: false,
    startParam: false
}

If you're following the model/store structure of Sencha, then you can just make a rest proxy for your store and tell it to include the id (which it does by default):

new Ext.data.Store({
    model: "comments",
    autoLoad: false,
    proxy: {
        type: 'rest',
        url: '/comments',
        appendId: true, //default
        noCache: false,
        limitParam: false,
        enablePagingParams: false,
        startParam: false
    }
});

// Collection url: /comments
// Instance url  : /comments/123

Lastly, you can use the buildUrl method on the proxy to create a custom Url format for the request.

Reference http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.Rest for more details.

Eric C
  • 832
  • 3
  • 8
  • 20
  • how to add limitParam as a RESTful parameter rather than "?limit=25" ? – Alex Chan May 16 '12 at 00:45
  • Can you give me an example of a RESTful URL you need? Something like /comments/limit/25? – Eric C May 16 '12 at 15:15
  • I just don't know to to define the RESTful URL~~ , is your example RESTful, or the mixed is also acceptable? – Alex Chan May 16 '12 at 15:59
  • You can use a querystring in a RESTful URL setting, but it doesn't follow the strict definition of correct use. Can you give me a concrete example of what you're trying to do? Reference http://stackoverflow.com/questions/3821663/querystring-in-rest-resource-url for RESTful best practice in reference to querystring. – Eric C May 16 '12 at 17:17
  • Thank you, I have a better understand about RESTful API – Alex Chan May 17 '12 at 09:52
  • Then , how to convert it to /comments/limit/25? – Alex Chan May 17 '12 at 13:36