Azure API management - AuthorizationFailed when using Subscription header key with url query params

Rioux, Jean-Philippe 21 Reputation points

I'm trying to understand a weird behavior when I'm using the Azure API management service.
I have an API with a Subscription required option enabled and I created a Subscription scoped to this new API.
When I call the API with the api-key in a request header, everything works ok.
But as soon as I add query params to the URL (?skip=0&take=2) I receive the following error

    "error": {  
        "code": "AuthorizationFailed",  
        "message": "The authentication credentials are not valid."  

I also tried to use a query param instead of the request header for the Subscription key but I have the same result.
Am I missing something here?

Thank you

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,861 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 69,846 Reputation points

    @Rioux, Jean-Philippe Thanks for reaching out. Any client sending requests to APIM could either add

    1. A Ocp-Apim-Subscription-Key Header with a valid subscription key
    2. A subscription-key query params with a valid subscription key

    You could acquire a subscription key from the developer portal or azure portal. You can read more about subscriptions in the docs.

    I have tested using the query params subscription-key with other query params to my request URL and I don't see any issue at my end. I have tested with api-key params and it always fails if there are no other params. APIM only looks for subscription-key query params when you are passing the authentication header as a query string.

    Please leverage the subscription-key query params and let me know if you still observe the issue.

0 additional answers

Sort by: Most helpful