-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restangular sends empty {} request payload when removing object #78
Comments
It's sending an empty request. I'll send nothing. Thanks for the report. |
I am experiencing this same problem. Is there a workaround please? I really like the look of this library and am trying to test it, but this problem is a show-stopper. I noticed that this error is coming from REXML. Is the content type json? Can I set the content type to json? |
Hey, I'm actually sending content type as JSon in both request and response. Anyway, I've just pushed the fix, but I haven't tagged yet. I'll be tagging tomorrow. Get the version from https://raw.github.com/mgonto/restangular/master/dist/restangular.js Thanks!!! |
it seems that now restangular sends object ID as a param: |
Can you please try the following? Add to your config: RestangularProvider.setRequestInterceptor(function(elem, operation) {
if (operation === "remove") {
return undefined;
}
return elem;
}) This way, you'll intercept whatever is being sent in remove and just send "undefined" |
Because I don't really want to remove this object being sent 100% from every DELETE request, as in other frameworks, it's needed. But, I think that if you just make your request interceptor return undefined for your rails app, it'll work :). The advantage of having this configurable. Please let me know if this works out. I think it's the best solution :) |
This works! Thanks! |
No problem :). I think this makes more sense. If you need to send nothing, you can do it in your configuration, so that you can choose what's sent. Also, for the rest of Rails methods, you're going to send a "root" object I think. So, you either change that configuration in your I'm glad it helps :) Closing now! |
Just a quick heads up: the code above didn't work for me - the operation is being sent as "delete", not remove. Therefore, this works: RestangularProvider.setRequestInterceptor(function(elem, operation) { |
Hey, i just started seeing this again, very weird i have other versions that are working. But my code is different as well. I set element to undefined. Could this be a "this" binding issue if i am doing something wierd? I also tried doing a Restangular.copy before the
|
Hey, Try setting null instead of undefined. I think maybe undefined has stopped working since new version with multiple interceptors. Thanks |
You are the man, thank you! |
I just had exactly the same issue but switching undefined to null as above fixed it for me (I'm using a Rails API backend). For reference:
|
This setting is also needed for Google App Engine backend APIs |
All of app engine. The weird thing is with the app engine dev server the delete body doesn't matter, just when you deploy does it hurt you! |
@j-walker23 I experienced the same confusion. Unpleasant surprise when you deploy :/ |
This setting is also needed when testing with Mockable.io. Caused a massive headache but luckily I found this thread. Would it not be possible to include this as a config flag? |
Just for the record - |
Where should I put this Code? RestangularProvider.setRequestInterceptor(function(elem, operation) { |
Rails application crashes with message "The document "{}" does not have a valid root" when making simple object remove.
Seems to be caused by {}:none request params which should not be included into DELETE request.
The text was updated successfully, but these errors were encountered: