Problem with trending on social networks API

RafaP 20 Reputation points
2023-03-03T14:08:38.31+00:00

Hi,

I'm trying to use trending api described here: https://learn.microsoft.com/en-us/bing/search-apis/bing-news-search/how-to/trending-news

I made this curl:

curl --header "Ocp-Apim-Subscription-Key: MY-SUBSCRIPTION-KEY" "https://api.cognitive.microsoft.com/bing/v7.0/news/trendingtopics?customconfig=MY-CUSTOMCONFIG&mkt=es-ES&setLang=ES"

but I always get this response:

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

Could you tell me what I'm doing wrong?

Thanks in advance, Rafa.

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 42,586 Reputation points Microsoft Employee
    2023-03-09T13:08:55.8566667+00:00

    RafaP I see you are using the endpoint https://api.cognitive.microsoft.com which is for bing resources which were created under cognitive services namespace i.e most likely before October 2020. Try using the API under bing https://api.bing.microsoft.com if you have recently created your resource.

    Your request should look like something below:

    curl -H "Ocp-Apim-Subscription-Key: <yourkeygoeshere>" "https://api.bing.microsoft.com/v7.0/news/trendingtopics?mkt=en-US"

    I hope this helps!!

    Update: Editing the endpoint params, did not edit the custom config params from the initial OP post while posting the answer.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful