I been trying to solve this error but I can't find what seems to be wrong.
I am using Microsoft Cognitive Services Face API
with python
. Here is my code:
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))
When I run the script I get:
"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."
The thing is that when I put the exact same Key on the console everything works fine. So I am pretty sure it is not the key.
The error must be on my code, but I can't find it.
Any tip in the right direction will be appreciated, Thanks