【问题标题】:Microsoft Face API [find similar] api key errorMicrosoft Face API [查找相似] api 密钥错误
【发布时间】:2018-09-28 03:05:59
【问题描述】:

所以我正在尝试遵循 microsoft face api 文档here 来获取“FindSimilar”功能。页面底部有一个我使用此代码的示例:

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{api key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
    conn.request("POST", "/face/v1.0/findsimilars?%s" % params, "{body}", 
headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

我收到一条错误消息,告诉我我的订阅密钥无效,但我检查了我的 azure 帐户状态,但没有发现任何问题:

b'\n\t\t\t\t\t{"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."}}\n                \t\t'

【问题讨论】:

  • 您是否删除了您的 API 密钥,或者您只是使用 {api key} 作为您的密钥?
  • @TwistedSim 在我运行它时使用我真正的 api 密钥,是的,很抱歉不清楚

标签: python-3.x azure azure-blob-storage face-api


【解决方案1】:

由于订阅密钥无效,访问被拒绝。确保您订阅了您尝试调用的 API 并提供正确的密钥。

表示Invalid subscription Key or user/plan is blocked。我建议你可以check the APi Key

headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '3c658abc64b348c1a5...',
}

【讨论】:

  • 我完全按照您的图片进行操作,但我仍然遇到同样的错误。即使我使用新的 api 密钥。我检查了我的 azure 门户以及您显示的链接,它说订阅处于活动状态。我不知道该怎么办
猜你喜欢
  • 1970-01-01
  • 2016-08-26
  • 2017-12-21
  • 1970-01-01
  • 2020-08-03
  • 2017-08-04
  • 2017-09-21
  • 1970-01-01
  • 2017-02-25
相关资源
最近更新 更多