Unable to retrieve images using ImageSearchClient with https://api.bing.microsoft.com/ endpoint

ac 1 Reputation point
2020-11-07T15:53:48.567+00:00

My requirement is to get images from the web. What I tried is -

I created a Bing search resource to get keys and endpoint. I now have two keys for the endpoint - https://api.bing.microsoft.com/

Ran the below code in a python notebook.

from azure.cognitiveservices.search.imagesearch import ImageSearchClient as api
from msrest.authentication import CognitiveServicesCredentials as auth

key = <value of my key>

client = api('https://api.bing.microsoft.com/', auth(key))
p = client.images.search(query='grizzly bear', count=1, min_height=128, min_width=128)

Last line gives a ErrorResponseException: Operation returned an invalid status code 'Resource Not Found' error.

Please advise.

Bing Image Search
Bing Image Search
A Bing service that supports searching for images and gets comprehensive results.
44 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,586 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Frik Botha 1 Reputation point
    2020-11-15T10:41:53.247+00:00

    Same problem here. I believe the part of the URL that is appended by ImageSearchClient may be incorrect, since I managed to get it working by using the more direct approach given in BingImageSearchv7.py.

    Removing "/bing" from "/bing/v7.0/images/search" fixed it for me (see this line).

    0 comments No comments

  2. YutongTie-MSFT 48,081 Reputation points
    2020-11-30T10:32:52.2+00:00

    Hello everyone,

    Sorry for the experience for this issue. We have forwarded this issue to engineering team for fixing. Thanks for your patient.

    Regards,
    Yutong

    0 comments No comments

  3. YutongTie-MSFT 48,081 Reputation points
    2020-12-09T11:39:35.983+00:00

    Hello everyone,

    We have new version SDK is releasing, so everything should be perfect soon. For now, please try following corrections which should fix this error:

    https://api.cognitive.microsoft.com/bing/v7.0 => https://api.bing.microsoft.com/v7.0/
    o For example https://api.cognitive.microsoft.com/bing/v7.0/search => https://api.bing.microsoft.com/v7.0/search
    https://api.cognitive.microsoft.com/bingcustomsearch/v7.0 => https://api.bing.microsoft.com/v7.0/custom
    o For example https://api.cognitive.microsoft.com/bingcustomsearch/v7.0/search => https://api.bing.microsoft.com/v7.0/custom/search
    o For example https://api.cognitive.microsoft.com/bingcustomsearch/v7.0/images/search => https://api.bing.microsoft.com/v7.0/custom/images/search

    Please let me know if above not fixes your error. Thanks. I will also share the details once I know the new releasing date.

    Regards,
    Yutong