1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    8
    Vote Rating
    0
    Answers
    1
    G_D is on a distinguished road

      0  

    Question Unanswered: RestProxy: Remove id in POST request URL

    Unanswered: RestProxy: Remove id in POST request URL


    Hi everybody,

    I'm having a problem posting new elements to a REST web service.
    The web service can be reached under /exercise and is used to catalogue excercises.
    Here the model:
    Code:
    Ext.regModel('Exercise', {
        proxy : {
            type : 'rest',
            url : 'http://localhost:8080/exercises',
        },
        fields : [
        {
            name : 'class',
            type : 'string'
        },{
            name : 'id',
            type : 'int'
        },{
            name : 'name',
            type : 'string'
        }, {
            name : 'description',
            type : 'string'
        }, {
            name : 'version',
            type : 'int'
        }]
    });
    and here the code for creating a new Object
    Code:
    newExercise = Ext.ModelMgr.create({
                name : 'Chin Up',
                description: 'Tuff stuff',
            }, 'Exercise');
            
    newEx.save();
    Since the webservice manages the asignement of ids to new objects the web service expects a post to look like this
    Code:
    POST /exercise/?_dc=...
    instead an id is added to the POST request, which causes the web servide to reply an error message.
    Code:
    POST /exercise/0?_dc=...
    Can I do anything about it?

    Thank you in advance

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,624
    Vote Rating
    435
    Answers
    3106
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Do you really need to use rest then? Maybe just ajax?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    8
    Vote Rating
    0
    Answers
    1
    G_D is on a distinguished road

      0  

    Default


    Well it's a fallback solution of course but it would be nice to use the restproxy.
    So deducting from your answer I have to overwrite the URL myself by extending the RestProxy?

    I guess it would be a nice improvement for a future release:
    Code:
    new Ext.data.RestProxy({    url:'/users',    appendIdToPost:true});
    Last edited by G_D; 3 Feb 2012 at 9:28 AM. Reason: error in the code section

Tags for this Thread