我一直在尝试解决此错误,但找不到似乎有问题的地方。
我正在Microsoft Cognitive Services Face API
使用python
. 这是我的代码:
import requests
import json
import http.client, urllib, base64, json
body = {"URL": "http://www.scientificamerican.com/sciam/cache/file/35391452-5457-431A-A75B859471FAB0B3.jsdfpg" }
headers = {
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": "xxx"
}
try:
r=requests.post('https://api.projectoxford.ai/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender',json.dumps(body) , headers)
print(r.content)
except Exception as e:
print(format(e))
当我运行脚本时,我得到:
"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."
问题是,当我将完全相同的密钥放在控制台上时,一切正常。所以我很确定这不是关键。
错误一定在我的代码上,但我找不到。
任何正确方向的提示将不胜感激,谢谢