javascript - Trouble changing Content-Type for POST requests with ngResource (1.0.6 and 1.1.4) -


first, know question has been asked several times. have tried many posted solutions , nothing working me..

here few other places asked:

the attempts:

var app = angular.module('theapp', ['app.services']);   app   .config(['$httpprovider', function ($httpprovider) {     // try (1): doesn't work     $httpprovider.defaults.headers.common['content-type'] = 'application/json;charset=utf-8';     // try (2): doesn't work either     $httpprovider.defaults.headers.post['content-type'] = 'application/json;charset=utf-8';   }])   angular.module('app.services', ['ngresource'])   // resource drupal system/connect.post api (via services.module)   .factory('systemconnect', function($resource, $http) {     // try (3): there's no way should work. hell let's try!     $http.defaults.headers.common['content-type'] = 'application/json;charset=utf-8';     $http.defaults.headers.post['content-type'] = 'application/json;charset=utf-8';      return $resource('api/system/connect.json', {}, {       post: {         method: 'post',         params: { },         isarray: true,         // try (4): doesn't work either         headers: { 'content-type': 'application/json;charset=utf-8' }       }     });   });   function somectrl($scope, systemconnect) {   // fail, results in "406 not acceptable: unsupported content type application/xml"   $scope.user = systemconnect.post(); } app.controller('somectrl', somectrl); 

it sounds many people have solved before. kindly let me know right way this?

ps: weirdly, when running code in firefox, angular uses 'content-type: text/plain' post!?

i remember reading have include content in post accept header changes.

$scope.user = systemconnect.post({}); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -