因此,我正在尝试关注“FindSimilar”功能的microsoft face api文档here。页面底部有一个示例,我使用此代码:
########### 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))
我收到错误,它告诉我我的订阅密钥无效,但我检查了我的帐户状态,我发现没有问题:
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'
答案 0 :(得分:0)
由于订阅密钥无效而拒绝访问。确保您订阅了您要拨打的API并提供了正确的密钥。
表示use strict;
use warnings;
print "Please type in your first name here :";
my $name = <STDIN>;
chomp($name); # $name = "Name";
my $function_applied_name = reverse($name);
$function_applied_name=~s/^([a-z])/my $nw=uc($1);/e; #First letter Upper case `uc`
$function_applied_name=~s/([A-Z])$/my $nw=lc($1);/e; #Last letter Lower case `lc`
print $function_applied_name;
。我建议您check the APi Key。
Invalid subscription Key or user/plan is blocked