Bing Custom Search not supported with current subscription

e_user_123 1 Reputation point
2021-02-09T09:54:03.59+00:00

I have the Bing Custom Search working in the Azure portal and on customsearch.ai, but when I try to access the endpoint from Postman or a js file I get this error:

 error: {
    code: '401',
    message: 'The Search Operation under Web Search API - v7 is not supported with the current subscription key and pricing tier Bing.CustomSearch.F0.'

}

This is the code I am running. The subscription key is definitely correct. When I change it I get a different error.

const https = require('https');

const SUBSCRIPTION_KEY = "*****************************"
if (!SUBSCRIPTION_KEY) {
  throw new Error('AZURE_SUBSCRIPTION_KEY is not set.')
}

function bingWebSearch(query) {
    https.get({
      hostname: 'api.bing.microsoft.com',
      path:     '/v7.0/search?q=' + encodeURIComponent(query),
      headers:  { 'Ocp-Apim-Subscription-Key': SUBSCRIPTION_KEY },
    }, res => {
      let body = ''
      res.on('data', part => body += part)
      res.on('end', () => {
        for (var header in res.headers) {
          if (header.startsWith("bingapis-") || header.startsWith("x-msedge-")) {
            console.log(header + ": " + res.headers[header])
          }
        }
        console.log('\nJSON Response:\n')
        console.dir(JSON.parse(body), { colors: false, depth: null })
      })
      res.on('error', e => {
        console.log('Error: ' + e.message)
        throw e
      })
    })
  }

  const query = process.argv[2] || 'Microsoft Bing Search Services'

  bingWebSearch(query)
Bing Custom Search
Bing Custom Search
An easy-to-use, ad-free, commercial-grade search tool that lets you deliver the results you want.
82 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. e_user_123 1 Reputation point
    2021-02-09T10:20:02.713+00:00

    I've now solved it - the url needed to include '/custom', and I also needed to pass in customConfig and mkt in the params.

    This was not in the documentation here - should it be updated? https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/quickstarts/rest/nodejs