HTTPError: 404 Client Error: Resource Not Found for url: https://api.bing.microsoft.com/bing/v7.0/images/visualsearch

PL Yap 26 Reputation points
2022-07-06T05:47:45.407+00:00

Hi,

I was trying the run the following code for bing visual search and I got the above error.
What is the cause of the error here ?

-------------------------------------------------------------------------------------------

BASE_URI = 'https://api.bing.microsoft.com/bing/v7.0/images/visualsearch'
SUBSCRIPTION_KEY = subscription_key
imagePath = 'blackdurian.png'
HEADERS = {'Ocp-Apim-Subscription-Key': SUBSCRIPTION_KEY}

file = {'image' : ('blackdurian', open(imagePath, 'rb'))}

def print_json(obj):
"""Print the object as json"""
print(json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': ')))

try:
response = requests.post(BASE_URI, headers=HEADERS, files=file)
response.raise_for_status()
print_json(response.json())

except Exception as ex:
raise ex

Bing Visual Search
Bing Visual Search
A Bing service that gives you rich insights to help build compelling image applications on the device of your choice.
25 questions
0 comments No comments
{count} votes

Accepted answer
  1. romungi-MSFT 46,831 Reputation points Microsoft Employee
    2022-07-06T10:25:21.45+00:00

    @PL Yap The correct endpoint should be the following:

    https://api.bing.microsoft.com/v7.0/images/visualsearch  
    

    218029-image.png

    Also, please ensure the correct pricing tier is used for your resource which supports visual search. Please see the table below for reference. I have used S9 tier for my call to the service above.

    218115-image.png

    If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.