I have tried the following command, using resource on Angular:
angular.module('appServices', ['ngResource']).factory('Example',
function($resource){
return $resource('http://api.example.com.br/teste', {}, {
query: {method:'GET', headers: {'Content-Type': 'application/json'}}
});
});
but the http content type is not being generated correctly, in this case "application/json".
I have seen similar questions like AngularJS resource not setting Content-Type ,but I have the lastest Angular version (1.0.6/1.1.4).
What is wrong with the code above?
Conclusion
- As mentioned bellow, HTTP Get method should not have a body.
- The attribute headers does not work in the version described above. I used the following command unsuccessfully: query: {method:'POST', headers: {'Content-Type': 'application/json'}}
- This way has worked for me: $http.defaults.headers.put['Content-Type'] = 'application/json';