Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

The remote server returned an error: (401) Unauthorized #45

Open
fazalabbas opened this issue Dec 6, 2017 · 4 comments
Open

The remote server returned an error: (401) Unauthorized #45

fazalabbas opened this issue Dec 6, 2017 · 4 comments

Comments

@fazalabbas
Copy link

This is similar to #35 but in my case, my first call failed instead of failing it later.

I am getting this error. I have generated multiple keys from my two MSDN accounts that came with my two different Visual Studio accounts. Same error.

I tried following as suggested by zhouwangzw. It is giving same 401
$FetchTokenHeader = @{
'Content-type'='application/x-www-form-urlencoded';
'Content-Length'= '0';
'Ocp-Apim-Subscription-Key' = 'YOUR_API_KEY'
}

Invoke-RestMethod -Method POST -Uri https://api.cognitive.microsoft.com/sts/v1.0/issueToken -Headers $FetchTokenHeader

My resource group being used has location "South Central US", my location is Colorado, my subscription is "Visual Studio Enterprise".

I there anything else I have to do AFTER generating key and BEFORE using it?

Thanks

@fazalabbas
Copy link
Author

fazalabbas commented Dec 6, 2017

Found something

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

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

So the key I generated was for South Central and the call was going to something non South Central.

Can someone tell what is the location I pick for my Region that the call I am making goes to right Default region? West Central US?

Just to clarify, I want to make call using Microsoft.ProjectOxford API. I dont want to make REST API call.

@zhouwangzw
Copy link
Contributor

Not sure I understand your question. The link you sent seems for TextAnalytics API, but not for Speech API. The same key can be used both in REST API or Speech SDK.

@fazalabbas
Copy link
Author

Sorry if i was not clear.

I meant, I want to make API call using NuGet package Microsoft.ProjectOxford. I dont want to make a call using REST API.

I am looking for a way to set Region while making call using OxfordProject Nuget package.

@zhouwangzw
Copy link
Contributor

You do not need to set region when using Speech API. Please see the steps and sample on this page for details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants