PDA

View Full Version : The ID element automatically attached to the Rest request URL



sj_tt6
7 Aug 2012, 3:52 PM
Hi,

I can not understand what causes the problem in my application. I have a model

proxy: {
type: 'rest',
url: 'services',
actionMethods: {
read: 'GET',
create: 'POST',
update: 'PUT',
destroy: 'DELETE'
},
reader: {
type: 'json',
root: 'results'
},
writer: {
type: 'json'
}
}

When I save or update a form that has a text field with id='id' among other fields, the request is sent to the URL http://...:8080/services/<id>?_dc=... and the error is (Invalid URI: noSlash).

Why is the id value in the form attached to the URL? :-/ I check the requests are HTTP PUT and the body is a JSON object that contains all data in my form including the id.

Thanks,

vietits
7 Aug 2012, 5:59 PM
Try to set appendId to false for your proxy. See more at "Url generation" section in Ext.data.proxy.Rest (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.proxy.Rest).


proxy: {
type: 'rest',
url: 'services',
appendId: false,
actionMethods: {
read: 'GET',
create: 'POST',
update: 'PUT',
destroy: 'DELETE'
},
reader: {
type: 'json',
root: 'results'
},
writer: {
type: 'json'
}
}

sj_tt6
8 Aug 2012, 7:17 AM
Thank you vietits, the problem is fixed.