I am learning how to use this API, to start with, i thought of running a simple program and this is what happens: code:
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}
params = {
'faceId1': '03ab5c58-86bb-4eef-a89e-56d4ce76e95b',
'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)
Output:
{'error': {'code': 'BadArgument', 'message': 'Request body is invalid.'}}
Here's how to solve it. I figured it out:
import json
subscription_key = "**"
assert subscription_key
face_api_url = 'https://centralindia.api.cognitive.microsoft.com/face/v1.0/verify'
headers = {'Ocp-Apim-Subscription-Key': subscription_key,'Content-Type':'application/json'}
params = {
"faceId1": "d4f201e1-8372-4295-ab91-5a148d5932e8",
"faceId2": "948fb955-5384-42e2-8623-2e44127163f6"
}
body1=json.dumps(params)
import requests
from pprint import pprint
response = requests.post(face_api_url, headers=headers, data=body1)
faces = response.json()
pprint(faces)