Like everyone else using the Bing Search API, I received an email from Azure telling me "Bing Search APIs will transition from Azure Cognitive Services to Azure Marketplace on 31 October 2023" I have a few questions about this change. In the email I received, it specifically lists the following services:
- Bing Auto Suggest
- Bing Custom Search
- Bing Entity Search
- Bing Spell Check
- Bing Web Search
but I'm using Bing News Search.
I'm assuming News is included in the list of services, but I want to make sure. I created a Bing Resource in Azure and I'm trying to use it to search news using my new API keys and the code at https://github.com/Azure-Samples/cognitive-services-REST-api-samples/blob/master/nodejs/Search/BingNewsSearchv7.js but when I connect to the service, I receive a Resource not found
error with a 404 response code.
Here's my code:
const BING_KEY = Config.BING_ACCESS_KEY;
const BING_HOST = "https://api.bing.microsoft.com/bing/v7.0/news/search";
const BING_MARKET = 'en-US';
const SEARCH_QUERY = 'pwa';
let request_params = {
method: 'GET',
uri: BING_HOST,
count: 20,
headers: { 'Ocp-Apim-Subscription-Key': BING_KEY },
qs: { q: SEARCH_QUERY, mkt: BING_MARKET },
json: true
}
// Call the Bing search API
request(request_params, (error: any, response: Response, body: any) => {
//@ts-ignore
console.log('statusCode:', response && response.statusCode);
if (error) console.error('error:', error);
//@ts-ignore
if (response && response.statusCode == 200) {
console.log('original query: ' + body.queryContext.originalQuery);
}
console.table(body);
});