Fazal Abbas
Fazal Abbas

Reputation: 1

The remote server returned an error: (401) Unauthorized in Microsoft.ProjectOxford

Call GetSentimentAsync is failing with error 401 as mentioned in title

var client = new SentimentClient(Constants.API_KEY);
var request = new SentimentRequest();
var response = await client.GetSentimentAsync(request);

My resource group for generating key in Azure has location "South Central US", my location is Colorado, my subscription is "Visual Studio Enterprise"

I used this page to test my service https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics.V2.0/operations/56f30ceeeda5650db055a3c7

If I use https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics.V2.0/operations/someID link to test call. It gives 401.

If I use https://southcentralus.dev.cognitive.microsoft.com/docs/services/TextAnalytics.V2.0/operations/someID/ then it is giving 200.

Seems like issue is related to the Region I selected at the time of creation of New Resource in Azure. Seems like default Region is not what I selected, South Central US

So, what should I do make my call succeed? Where I can mention region in making API call?

Thanks Abbas

Upvotes: 0

Views: 1638

Answers (2)

maheshpardeshi
maheshpardeshi

Reputation: 21

Solved It. I just check what is end point I am hitting from my program using fiddler and it was westus Just create Azure end point with westus region.

Upvotes: 1

Ronak
Ronak

Reputation: 736

Location is in the API call itself: https://[location].api.cognitive.microsoft.com/text/analytics/v2.0/sentiment. In your case, you should use southcentralus in place of [location].

Example of POST request is on this page: https://southcentralus.dev.cognitive.microsoft.com/docs/services/TextAnalytics.V2.0/operations/56f30ceeeda5650db055a3c9/console.

Upvotes: 0

Related Questions