"statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }

Bill dim 21 Reputation points
2021-12-17T10:10:23.31+00:00

I am sending the right subscription key in the following code, but I am getting the message : "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }

Can someone help me please?

Here is my code:

Const URL1 = "https://data-dev.azure-api.net/Senddata"

Set XMLServer = CreateObject("WinHttp.WinHttpRequest.5.1")
Set XMLReceive = CreateObject("Msxml2.DOMDocument.6.0")
XMLServer.SetTimeouts 5000, 60000, 10000, 10000
'
XMLServer.Option(9) = 2048
XMLServer.Option(6) = True

XMLServer.Open "POST", URL1, True
XMLServer.SetRequestHeader "aade-user-id", p_USER
XMLServer.SetRequestHeader "ocp-apim-subscription-key", p_Key
XMLServer.Send XMLFile
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,659 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mike Urnun 9,081 Reputation points Microsoft Employee
    2021-12-17T21:53:43.59+00:00

    Hello @Bill dim - Did you verify if a correct subscription ID is being used against the API that's associated with the correct Product in your APIM setup? Troubleshooting steps for the error message is documented at the following: Unauthorized errors (401) while invoking APIs

    I hope the steps above help but let me know if you continue to encounter this problem.


0 additional answers

Sort by: Most helpful