Ocp-Apim-Subscription-Key is not working

Ambi Tamber 41 Reputation points
2020-12-08T03:26:53.24+00:00

I am trying to use Bing News api v7.
I got the key from Bing resources > name of resource > Keys and Endpoint.

When I try to get information from this endpoint, I am getting this.
https://api.bing.microsoft.com/v7.0/search/?q=microsoft+devices&Ocp-Apim-Subscription-Key=xxx

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

Bing News Search
Bing News Search
A Bing service that supports searching for news and get comprehensive results.
43 questions
{count} votes

Accepted answer
  1. romungi-MSFT 41,861 Reputation points Microsoft Employee
    2020-12-08T06:04:21.353+00:00

    @Ambi Tamber To use the news API please use the following in your request URL and the subscription key should be part of the header instead of the query parameter. You can run a GET query with the following details:

    https://api.bing.microsoft.com/v7.0/news/search?q=microsoft  
    

    Header for this request should be your key:

    Ocp-Apim-Subscription-Key: <your_key>

    P.S: I have updated the post to remove your keys.


1 additional answer

Sort by: Most helpful
  1. Ambi Tamber 41 Reputation points
    2020-12-12T02:04:05.137+00:00

    This is working for me. Thanks.

    0 comments No comments