1

I have been following https://aischool.microsoft.com/en-us/services/learning-paths/sketch2code tutorial,

  • i have created Custom Vision instance in US West 2 region
  • trained sample image with 2 tags
  • change the key value in Program.cs file, if i run "dotnt run" command, getting the following error

Unhandled Exception: Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'Unauthorized' at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.TrainingApi.GetDomainsWithHttpMessagesAsync(Dictionary`2 customHeaders, CancellationToken cancellationToken) at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.TrainingApiExtensions.GetDomainsAsync(ITrainingApi operations, CancellationToken cancellationToken) at Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training.TrainingApiExtensions.GetDomains(ITrainingApi operations) at Import.Program.Main(String[] args) in F:\Microsoft AI\AISchoolTutorials-master\AISchoolTutorials-master\sketch2code\Import\Program.cs:line 29

Please help to resolve, thanks in advance

adarsh
  • 119
  • 3
  • 13

1 Answers1

0

If you're getting an Unauthorized error, that usually means that the training key you're using to call the API isn't correct, or you haven't configured the header correctly. If you want to double check the training key, you'll want to refer to the training keys visible in the Azure Portal view for your resource. You should also be able to see this key via the "settings" page in the Custom Vision portal at www.customvision.ai.

Also, if you want to sanity check that your key is working correctly, you can use the API Reference for the GetDomains API, and you can plug in the training key and test out the call (or copy the generated curl command). Below is the API reference page for West US 2: https://westus2.dev.cognitive.microsoft.com/docs/services/Custom_Vision_Training_3.3/operations/5eb0bcc6548b571998fddeab/console