I'm sending an ajax request to the Bing Search API. The URL I am using for the request works when I put it in the browser. With ajax I get a 401 error "The authorization type you provided is not supported. Only Basic and OAuth are supported"
therefore my header is wrong. It works in the browser because I manually type in my azure account key.
<script>
$scope.bingsearch = function() {
var azurekey = '....vjrQiHPp4ct1meqroX2pzQZhPvE';
var keywords = $scope.inputvalue;
var myurl = 'https://api.datamarket.azure.com/Bing/Search/v1/Composite?
Sources=%27web%27&$format=json&Query=%27'+ keywords + '%27';
$http({
method: 'POST',
url: myurl,
headers:{
'Authorization': 'Basic ' + azurekey
}
}).success(function(data){
var searchresults = angular.fromJson(+data);
$scope.searchresult = searchresults;
})
};
</script>
The URL https://api.datamarket.azure.com/Bing/Search/v1/Composite?Sources=%27web%27&$format=json&Query=%27van%20gogh%27
works in the browser.
How do I set my header so that it will accept my account key?