In the UWP application development process, if you want to use Microsoft Cognitive Services, many developers will use the NuGet packages of Microsoft.Oxford.Face and Microsoft.Oxford.Vision. If you are debugging in visual studio, an exception message will pop up, such as "VIsionCLient has thrown an exception". At this time, we must pay attention to the Endpoint and Key of the cognitive service.
Take the cognitive service that many developers apply for trial as an example: (URL is: https://westcentralus.api.cognitive.microsoft.com/vision/v1.0 ), the information is as follows:
You can see the corresponding endpoint Endpoint and Key.
When invoking the service, you need to define its Endpoint and Key. Take the face recognition service Face API as an example. When creating a new FaceServiceClient class, pass in Key and Endpoint as parameters, as shown below.
FaceServiceClient f_client = new FaceServiceClient(key_face, "https://westcentralus.api.cognitive.microsoft.com/face/v1.0");
If the key and the endpoint are not aligned, an exception will be raised. "HTTP 401 Access Denied error with a message "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription."