The endpoint param is not working when calling NewsSearchClient.news.search

Frank Chu 0 Reputation points
2023-07-10T04:03:14.28+00:00

Hey community,

I'm new to Azure. I try to follow https://learn.microsoft.com/en-us/bing/search-apis/bing-news-search/quickstarts/sdk/news-search-client-library-python here to use SDK to call my bing search endpoint.

It has a example code

from azure.cognitiveservices.search.newssearch import NewsSearchClient

from msrest.authentication import CognitiveServicesCredentials

subscription_key = "YOUR-SUBSCRIPTION-KEY"

endpoint = "YOUR-ENDPOINT"

search_term = "Quantum Computing"

The endpoint i found is from the Keys and Endpoint tab in my resource and the endpoint is just https://api.bing.microsoft.com/ , but when I try to run the code, it shows ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'

Looks like i'm entering the wrong endpoint? So where can i find the correct one?

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

1 answer

Sort by: Most helpful
  1. VasaviLankipalle-MSFT 18,296 Reputation points
    2023-07-10T23:34:32.5166667+00:00

    Hello @Frank Chu , Thanks for using Microsoft Q&A platform.

    Firstly, try to create a Bing news search service resource by following this documentation: https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/create-bing-search-service-resource#create-your-bing-resource

    Once you have the resource you can copy the either of the Keys and the endpoint from the Bing news search service resource you have created by navigating to Azure portal. Try these and see if that helps.User's image

    If you have still face issues. I would recommend you regenerate the keys in the Azure portal as shown in the screenshot.

    I hope this helps.

    Regards,
    Vasavi

    -Please kindly accept the answer and vote 'yes' if you feel helpful to support the community, thanks.

    0 comments No comments

Your answer

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