Hello,
We have internal update for the URL, please use this URL and it should work: search_url = "https://api.bing.microsoft.com/v7.0/images/search"
We are working on updating all samples and documents. Thanks a lot!
Regards,
Yutong
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Recently tried using the Bing Image Search API functionality using this guide provided by Microsoft, using their own "binder" notebook with no luck. I ran it on my own Jupyter Notebook and server with the same result: a Client Error 401, Permission Denied. Other problems suggested the API key was input incorrectly, but after numerous testing this does not appear to be the case. Here is the full output of the Error callback:
HTTPError Traceback (most recent call last)
<ipython-input-6-c1121699867c> in <module>
4 params = {"q": search_term, "license": "public", "imageType": "photo"}
5 response = requests.get(search_url, headers=headers, params=params)
----> 6 response.raise_for_status()
7 search_results = response.json()/srv/conda/envs/notebook/lib/python3.7/site-packages/requests/models.py in raise_for_status(self)
933
934 if http_error_msg:
--> 935 raise HTTPError(http_error_msg, response=self)
936
937 def close(self):HTTPError: 401 Client Error: PermissionDenied for url: https://api.cognitive.microsoft.com/bing/v7.0/images/search?q=puppies&license=public&imageType=photo
Hello,
We have internal update for the URL, please use this URL and it should work: search_url = "https://api.bing.microsoft.com/v7.0/images/search"
We are working on updating all samples and documents. Thanks a lot!
Regards,
Yutong
Hey @YutongTie-5848 , I am currently using the ImageSearchClient api and getting a 'Resource Not Found error' (full error posted below). Is only the REST API available or is the ImageSearchClient API for Python also available?
---------------------------------------------------------------------------
ErrorResponseException Traceback (most recent call last)
<ipython-input-5-f9ef654a8ee3> in <module>
9 #results = search_images_google(google_key, f'{o}')
10 #download_images(dest, urls=results.attrgot('link'))
---> 11 results = search_images_bing(ms_key, f'{o}')
12 download_images(dest, urls=resutls.attrgot('content_url'))
13
/notebooks/personal/climax/easter-egg/utils.py in search_images_bing(key, term, min_sz)
31 def search_images_bing(key, term, min_sz=128):
32 client = api("https://api.bing.microsoft.com/v7.0/images/search", auth(key))
---> 33 return L(client.images.search(query=term, count=150, min_height=min_sz, min_width=min_sz).value)
34
35 def search_images_google(key, term, min_sz=128, start=1, num=10,exp=False, search_engine="1255cf7ee95a87668"):
/opt/conda/envs/fastai/lib/python3.8/site-packages/azure/cognitiveservices/search/imagesearch/operations/_images_operations.py in search(self, query, accept_language, user_agent, client_id, client_ip, location, aspect, color, country_code, count, freshness, height, id, image_content, image_type, license, market, max_file_size, max_height, max_width, min_file_size, min_height, min_width, offset, safe_search, size, set_lang, width, custom_headers, raw, **operation_config)
489
490 if response.status_code not in [200]:
--> 491 raise models.ErrorResponseException(self._deserialize, response)
492
493 deserialized = None
ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'
Hey @YutongTie-5848 , I am currently using the ImageSearchClient api and getting a 'Resource Not Found error' (full error posted below). Is only the REST API available or is the ImageSearchClient API for Python also available?
---------------------------------------------------------------------------
ErrorResponseException Traceback (most recent call last)
<ipython-input-5-f9ef654a8ee3> in <module>
9 #results = search_images_google(google_key, f'{o}')
10 #download_images(dest, urls=results.attrgot('link'))
---> 11 results = search_images_bing(ms_key, f'{o}')
12 download_images(dest, urls=resutls.attrgot('content_url'))
13
/notebooks/personal/climax/easter-egg/utils.py in search_images_bing(key, term, min_sz)
31 def search_images_bing(key, term, min_sz=128):
32 client = api("https://api.bing.microsoft.com/v7.0/images/search", auth(key))
---> 33 return L(client.images.search(query=term, count=150, min_height=min_sz, min_width=min_sz).value)
34
35 def search_images_google(key, term, min_sz=128, start=1, num=10,exp=False, search_engine="1255cf7ee95a87668"):
/opt/conda/envs/fastai/lib/python3.8/site-packages/azure/cognitiveservices/search/imagesearch/operations/_images_operations.py in search(self, query, accept_language, user_agent, client_id, client_ip, location, aspect, color, country_code, count, freshness, height, id, image_content, image_type, license, market, max_file_size, max_height, max_width, min_file_size, min_height, min_width, offset, safe_search, size, set_lang, width, custom_headers, raw, **operation_config)
489
490 if response.status_code not in [200]:
--> 491 raise models.ErrorResponseException(self._deserialize, response)
492
493 deserialized = None
ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'
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