azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Solved Bing Search API "Resource Not Found" error

Open lorenzobalzani opened this issue 2 years ago • 2 comments

Description

I solved this issue. I just changed url = self._client.format_url(url, **path_format_arguments) to url = path_format_arguments['Endpoint'] and the problem has been resolved.

All SDK Contribution checklist:

  • [X] The pull request does not introduce [breaking changes]
  • [X] CHANGELOG is updated for new features, bug fixes or other significant changes.
  • [X] I have read the contribution guidelines.

General Guidelines and Best Practices

  • [X] Title of the pull request is clear and informative.
  • [X] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • [ ] Pull request includes test coverage for the included changes.

lorenzobalzani avatar Jan 15 '24 14:01 lorenzobalzani

Thank you for your contribution @lorenzobalzani! We will review the pull request and get back to you soon.

github-actions[bot] avatar Jan 15 '24 14:01 github-actions[bot]

@lorenzobalzani thanks for looking into this. The code in this PR is auto-generated (you can tell by the header at the top of the file) and so we cannot edit it directly since it will be overwritten the next time the code is generated. Adding @msyyc to comment on if this fix is needed in the generator to address the issue.

kristapratico avatar Jan 17 '24 00:01 kristapratico

@msyyc

lorenzobalzani avatar Jan 17 '24 13:01 lorenzobalzani

@kristapratico According to github history, the code was generated several years ago and not updated for 5 years. I don't know whether there is plan to regenerate for a regular release so I feel OK for this manual fix.

msyyc avatar Jan 22 '24 01:01 msyyc

@lorenzobalzani I'm trying to understand the fix - is it the /bing/ in the path that's the problem? Looking here it seems like we should be building the URL as https://api.bing.microsoft.com/v7.0/search. I want to make sure that if we accept a manual change, it doesn't require the user to pass in the full URL as endpoint=https://api.bing.microsoft.com/v7.0/search (as that's inconsistent with how all other Azure client libraries work).

Would removing /bing on this line fix the issue?

https://github.com/Azure/azure-sdk-for-python/blob/89fb20c33835d99e665e4a8c5ba9ed6ed1c7c8fa/sdk/cognitiveservices/azure-cognitiveservices-search-websearch/azure/cognitiveservices/search/websearch/_configuration.py#L38

I think this change would be preferable since it would allow for a client to still be created like:

client = WebSearchClient(endpoint="https://api.bing.microsoft.com", credentials="apiKey")

kristapratico avatar Jan 23 '24 21:01 kristapratico

@lorenzobalzani I followed up on this and unfortunately this library is deprecated and so we won't be making any code changes or releases in the future. Apologize for the inconvenience.

kristapratico avatar Jan 25 '24 22:01 kristapratico