question

yjosms-2111 avatar image
1 Vote"
yjosms-2111 asked MikaelBerglund-3663 commented

Bing Search API returns the "Resource Not Found" error

I'm following the quickstart code here: https://docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/quickstarts/client-libraries?pivots=programming-language-python
I'm using a Bing Resource with the Free Tier.
The endpoint I'm using is https://api.bing.microsoft.com/

When I hit web_data = client.web.search(query="Yosemite"), I receive the following error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/yohanjo/anaconda/lib/python3.8/site-packages/azure/cognitiveservices/search/websearch/operations/_web_operations.py", line 371, in search
raise models.ErrorResponseException(self._deserialize, response)
azure.cognitiveservices.search.websearch.models._models_py3.ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'



I also tried creating a Cognitive Services resource and running the same code.
Now the endpoint is https://yjosms-test1.cognitiveservices.azure.com/ with the eastus region.
I'm getting the following error now:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/yohanjo/anaconda/lib/python3.8/site-packages/azure/cognitiveservices/search/websearch/operations/_web_operations.py", line 371, in search
raise models.ErrorResponseException(self._deserialize, response)
azure.cognitiveservices.search.websearch.models._models_py3.ErrorResponseException: Operation returned an invalid status code 'Forbidden'

I'm not located in the US physically, though, if that is relevant at all.

Why am I getting these errors and how to solve the issue?

azure-cognitive-servicesazure-bing-web
· 5
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.

@yjosms-2111 Thanks for reporting your issue. This error seems to be due to the recent migration of the service from cognitive services to bing, our team is aware of the same and are working to update the SDKs accordingly. You can use the existing keys directly with the REST API to get the correct response. We understand that this could be a frustrating experience until the SDKs are updated, we will update this issue with more details as soon as we have a fix. Thanks!!

0 Votes 0 ·

Thanks, @romungi-MSFT
The sample code for the REST APIs in the official doc (https://docs.microsoft.com/en-us/azure/cognitive-services/bing-web-search/quickstarts/python) doesn't work.
After many trials, I changed the search_url to https://api.bing.microsoft.com/v7.0/search and it works now.
It would be really helpful if the doc is updated properly since this issue is really tricky to resolve.

2 Votes 2 ·

@yjosms-2111 Thanks for the response. Yes, the REST API with the above endpoint works but the client SDK still fails. Our team is currently looking to fix this soon.

0 Votes 0 ·
Show more comments

Changing to that url worked for me as well, thanks.

0 Votes 0 ·

0 Answers