angularjs - Restangular and Rails, DELETE 406 not acceptable, Curl working -


why restangular 406 error, when want delete user? curl request working:

curl -x delete -v "http://localhost:3000/api/v1/users/1" 

this restangular method:

removeone: function(user) {       var deferred;       deferred = $q.defer();       if (_.isundefined(user.id) || _.isnan(user.id)) {         alertsserv.logerror(err);         deferred.reject(err);       } else {         user.remove().then(function(result) {           return deferred.resolve(result);         }, function(err) {           alertsserv.logerror(err);           console.log(err);           return deferred.reject(err);         });       }       return deferred.promise;     }  

and rails method (i'm using grape framework):

    delete ':id'       user = user.find(params[:id])       user.update(hidden: true)       user     end 

request server:

referer:  http://localhost:4400/users origin: http://localhost:4400 host: localhost:3000 content-type: text/plain; charset=utf-8 content-length: 263 connection: keep-alive accept-language:  pl,en-us;q=0.7,en;q=0.3 accept-encoding:  gzip, deflate accept: application/json, text/plain, */* 

response server:

x-runtime:  0.002188 x-request-id: 3aa91d50-c9f7-477d-812c-6a53b121a0d8 vary: origin server: webrick/1.3.1 (ruby/2.2.0/2014-12-25) date: wed, 15 apr 2015 19:35:57 gmt content-type: application/json content-length: 69 connection: keep-alive cache-control:  no-cache access-control-max-age: 1728000 access-control-allow-origin:  http://localhost:4400 access-control-allow-methods: get, post, put, delete, patch, options access-control-allow-credentials: true 

curl headers:

* connected localhost (127.0.0.1) port 3000 (#0) > delete /api/v1/users/1 http/1.1 > user-agent: curl/7.35.0 > host: localhost:3000 > accept: */* >  < http/1.1 200 ok  < content-type: application/json < content-length: 266 < etag: w/"9a1f921e10b819161e3d40f70cb7e123" < cache-control: max-age=0, private, must-revalidate < x-request-id: 5ebd11b0-fbcc-4728-9aed-eda08b553ede < x-runtime: 0.028572 * server webrick/1.3.1 (ruby/2.2.0/2014-12-25) not blacklisted < server: webrick/1.3.1 (ruby/2.2.0/2014-12-25) < date: wed, 15 apr 2015 19:39:59 gmt < connection: keep-alive 

just add restangularprovider.setdefaultheaders({'content-type': 'application/json'}) module.config.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -