face-detectionazure-cognitive-servicesface-api

Access denied due to invalid subscription key (Face API)


I am having trouble using Microsoft Face API. Below is my sample request:

curl -v -X POST "https://westus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=age,gender" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: 1xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxd" --data-ascii "{\"url\":\"http://www.mrbeantvseries.co.uk/bean3.jpg\"}"

I use the subscription id from my cognitive services account and I got below response:

{
  "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."
  }
}

Not sure if I've missed out anything there. Can someone help me on this? Very much appreciated.


Solution

  • It appears that you've entered your Azure subscription ID instead? In the Azure portal, you can find the API key under 'Keys', shown below:

    Azure Portal screenshot

    It will be a 32-digit hexadecimal number, no hyphens.