由于订阅密钥无效而拒绝访问(Face API)

Ahm*_*han 11 face-detection microsoft-cognitive face-api

我在使用Microsoft Face API时遇到问题.以下是我的示例请求:

curl -v -X POST "https://westus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: 1xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxd" --data-ascii "{\"url\":\"http://www.mrbeantvseries.co.uk/bean3.jpg\"}"
Run Code Online (Sandbox Code Playgroud)

我使用来自我的认知服务帐户的订阅ID,我收到以下回复:

{
  "error": {
    "code": "Unspecified",
    "message": "Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key."
  }
}
Run Code Online (Sandbox Code Playgroud)

不确定我是否错过了那里的任何东西.有人可以帮我吗?非常感谢.

Ces*_*arB 10

我遇到了同样的问题.我阅读了API文档,并说明了以下内容.

您必须在REST API调用中使用与获取订阅密钥相同的区域.

首先,您必须找到订阅的位置. 要查找订阅区域的位置,您必须转到标签位置下的认知服务 - >属性,您将找到您的订阅区域.见下文.在此输入图像描述

其次,你必须找到正确的终点来进行调用. 例如,如果我想调用Computer Vision API,我的位置是美国东部,我将使用密钥1或2,然后我将使用以下端点East US - https://eastus.api.cognitive .microsoft.com /脸/ V1.0 /检测

您现在可以访问API了.


Sib*_*enu 7

我遇到了同样的问题,似乎新生成的密钥存在一些问题.为了解决这个问题,您可以在创建对象时实际添加端点IFaceServiceClient.你可以看到下面的代码.

private readonly IFaceServiceClient faceServiceClient = new FaceServiceClient("your key", "Your endpoint");
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


小智 6

您似乎已输入Azure订阅ID?在Azure门户中,您可以在"密钥"下找到API密钥,如下所示:

Azure门户截图

它将是一个32位十六进制数字,没有连字符.