question

AmbiTamber-2171 avatar image
0 Votes"
AmbiTamber-2171 asked AshutoshSharma-6584 published

Ocp-Apim-Subscription-Key is not working

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

azure-bing-news
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Make sure you have the same name of Ocp-Apim-Subscription-Key into APIM API setting for Query parameter name

0 Votes 0 ·
romungi-MSFT avatar image
0 Votes"
romungi-MSFT answered romungi-MSFT commented

@AmbiTamber-2171 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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AmbiTamber-2171 Did you get a chance to review the above response and try the correct API endpoint with your keys?

0 Votes 0 ·
AmbiTamber-2171 avatar image
0 Votes"
AmbiTamber-2171 answered

This is working for me. Thanks.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.