Microsoft Face API验证(面对面)下来了吗?总是说错误的请求和文档​​控制台显示错误

Is Microsoft Face API verification (face to face) down? Always says bad request and documentation console shows error

这是我一直在尝试的:

subscription_key = "***"
assert subscription_key

face_api_url = 'https://southeastasia.api.cognitive.microsoft.com/face/v1.0/verify'


headers = {'Ocp-Apim-Subscription-Key': subscription_key,'Content-Type':'application/json'}
params = {
    "faceId1": "a1cadf80-d780-4b6a-8cef-717548a07e51",
    "faceId2": "05113848-2c22-4116-8a30-5cde938eec61"
}


import requests
from pprint import pprint
response  = requests.post(face_api_url, headers=headers, params=params)
faces = response.json()
pprint(faces)

我总是得到这个输出

{'error': {'code': 'BadArgument', 'message': 'Request body is invalid.'}}

此外,我已经尝试了 API 测试控制台,它总是导致面对面的错误(没试过其他的) 这是文档的 link,您可以在其中获取 link 到 API 测试控制台。 https://southeastasia.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523a

根据验证 API 我们可以知道人脸应该在 body 部分而不是 params

subscription_key = "xxxx"
assert subscription_key
import json
face_api_url = 'https://westus.api.cognitive.microsoft.com/face/v1.0/verify'
headers = {'Ocp-Apim-Subscription-Key': subscription_key,'Content-Type':'application/json'}
faces = {
    "faceId1": "xxxxxxxx",
    "faceId2": "xxxxxx"
}

body = json.dumps(faces)
import requests
from pprint import pprint
response  = requests.post(face_api_url, headers=headers,data=body)
result = response.json()
pprint(result)

测试结果:

我们也可以使用 python SDK

轻松做到这一点
import cognitive_face as CF
KEY = 'xxxxxx'  # Replace with a valid subscription key (keeping the quotes in place).
CF.Key.set(KEY)

BASE_URL = 'https://{location}.api.cognitive.microsoft.com/face/v1.0'  # Replace with your regional Base URL
CF.BaseUrl.set(BASE_URL)
result = CF.face.verify("faceId1","faceId2")
print(result)