Closed briannoyes closed 7 years ago
I am on the same boat. It throws an exception on every feature. When I tried OCR, it says my key is not valid but I am literally copying and pasting from the Microsoft website... the key is indeed valid.
The error is somewhere on the api key. Despite being given an official key from Microsoft, the request doesn't accept it. I get a 401 error.
Are either of you using the 'Try Free' API key? If so, you must use the VisionServiceClient.ctor override, and provide the host address (2nd arg) of https://westcentralus.api.cognitive.microsoft.com/vision/v1.0
.
Aligning the region my keys were for with the region being called fixed the problem for me. Since the region being called is buried in the code, I'd suggest making that a prompt along with the key, or somehow make it clear that the code has a specific region buried in the code that they will need to change if their keys are from a different region.
Thanks @briannoyes This was a recent change, and we haven't yet updated the sample apps to support the region specificity, its on our backlog and we'll update the apps to prompt for a region in the future.
I haven't had the time to try it, but does this solve the issue? Worth a try
yep, looks like that will help
Here is what gets dumped in the console: [16:11:51.353827]: VisionServiceClient is created [16:11:51.355825]: Calling VisionServiceClient.AnalyzeImageAsync()... [16:11:53.596602]: Microsoft.ProjectOxford.Vision.ClientException: Exception of type 'Microsoft.ProjectOxford.Vision.ClientException' was thrown. at Microsoft.ProjectOxford.Vision.VisionServiceClient.HandleException(Exception exception) at Microsoft.ProjectOxford.Vision.VisionServiceClient.b__42_1[TRequest,TResponse](Exception e)
at System.AggregateException.Handle(Funcd21`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ProjectOxford.Vision.VisionServiceClient.d 20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiterd3.MoveNext() in C:\Demos\Cortana\Cognitive-Vision-Windows\Sample-WPF\AnalyzePage.xaml.cs:line 141
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at VisionAPI_WPF_Samples.ImageScenarioPage.d 15.MoveNext() in C:\Demos\Cortana\Cognitive-Vision-Windows\Sample-WPF\ImageScenarioPage.cs:line 90
2 predicate) at Microsoft.ProjectOxford.Vision.VisionServiceClient.<SendAsync>d__42
2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ProjectOxford.Vision.VisionServiceClient.1.GetResult() at VisionAPI_WPF_Samples.AnalyzePage.<UploadAndAnalyzeImage>d__1.MoveNext() in C:\Demos\Cortana\Cognitive-Vision-Windows\Sample-WPF\AnalyzePage.xaml.cs:line 86 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult() at VisionAPI_WPF_Samples.AnalyzePage.