I'm trying to get data from a server that prefers to send XML. I don't think Angular supports that, so I want JSON.
As far as I understand, I should be able to set different headers, right? I'm doing what the docs say I should do,
but it doesn't seem to work. Here's what I do:
$http({
method: "JSONP",
params: params,
headers: {
'Accept':'application/json, text/javascript'
},
callback: 'JSON_CALLBACK',
isArray: false
});
I also tried it with a $resource:
fetch: {
method:'JSONP',
params: params,
headers: {'Accept':'application/json, text/javascript', 'Content-Type':'application/json; charset=utf-8'},
isArray:false,
callback: 'JSON_CALLBACK'
}
});
In desperation, I also tried this:
app.config(['$httpProvider', function($httpProvider){
$httpProvider.defaults.headers.common['Accept'] = 'application/json, text/javascript';
$httpProvider.defaults.headers.common['Content-Type'] = 'application/json; charset=utf-8';
}]);
None of this works. Angular keeps using Accept: */* in the request headers.
Am I doing something wrong, or is this simply not supported by Angular (despite the docs suggesting it is)?
I've tried this with both 1.0.7 and 1.2.3.
Regards,
Martijn Vos.