-
3 Feb 2012 8:41 AM #1
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:
and here the code for creating a new ObjectCode: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' }] });
Since the webservice manages the asignement of ids to new objects the web service expects a post to look like thisCode:newExercise = Ext.ModelMgr.create({ name : 'Chin Up', description: 'Tuff stuff', }, 'Exercise'); newEx.save();
instead an id is added to the POST request, which causes the web servide to reply an error message.Code:POST /exercise/?_dc=...
Can I do anything about it?Code:POST /exercise/0?_dc=...
Thank you in advance
-
3 Feb 2012 9:06 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
- Answers
- 3106
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 Feb 2012 9:26 AM #3
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


Reply With Quote