Share via

Access denied due to invalid subscription key or wrong API endpoint

Zili Yang 5 Reputation points
2024-01-06T17:34:57.0866667+00:00

Hi, I just created a new subscription to Bing Web search API under S6 Pricing tier, and I tried the new key and search_url ("https://api.bing.microsoft.com/v7.0/search"). However, the results returned

{"error":{"code":"401","message":"Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource."}}


But it just worked for my free pricing tier. I just changed keys and nothing else.

BTW, I am using Python to call the search.

Thanks for your help!

Bing | Bing Search APIs | Bing Web Search API

1 answer

Sort by: Most helpful
  1. navba-MSFT 27,620 Reputation points Microsoft Employee Moderator
    2024-01-08T09:24:37.3266667+00:00

    @Zili Yang Thanks for using Microsoft Q&A Platform.
    .

    Please make sure you are using correct subscription key or API endpoint.
    .

    I have reproduced this everything works well on my end. Here's the CURL command again for your reference please try this:

    curl -H "Ocp-Apim-Subscription-Key: <yourkeygoeshere>" https://api.bing.microsoft.com/v7.0/search?q=microsoft+devices
    

    Replace YOUR_SECRET_KEY with your actual subscription key. If the issue still persists, I would recommend regenerating your subscription key in the Azure portal and try again.

    I hope this helps.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.