Reputation: 647
I am trying to call bing text to speech azure services but i keep getting this error on getting the access token , although the subscription key is provided
function requestAudio(text,lang)
{
nameLanguage = "Microsoft Server Speech Text to Speech Voice (en-GB, Susan, Apollo)";
language = lang;
textToSpeak = text;
$.ajax(
{
type: 'POST',
url: tokenURL,
data:
{
'Ocp-Apim-Subscription-Key': 'xxxxxxf8cc34d08b646de1bc54c950d'
}
}).done(function(data)
{
token = data.access_token;
sendAudioRequest();
});
}
The error exactly from fiddler is
{ "statusCode": 401, "message": "Access denied due to missing subscription key. Make sure to include subscription key when making requests to an API." }
and the url i am calling is
https://api.cognitive.microsoft.com/sts/v1.0/issueToken
Upvotes: 1
Views: 6395
Reputation: 72191
I'm pretty sure you have to set those in the header, not in the body.
beforeSend: function(request) {
request.setRequestHeader("Ocp-Apim-Subscription-Key", 'xxxxxxf8cc34d08b646de1bc54c950d');
},
Reference: https://msdn.microsoft.com/en-us/library/mt712546.aspx
Upvotes: 5