【发布时间】: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