question

ChrisDiehl-8801 avatar image
0 Votes"
ChrisDiehl-8801 asked ChrisDiehl-8801 commented

Unable to obtain results with Entity Search Python library or query to REST API

I just attempted my first entity search query with the Python library and by sending a query to the REST API. In both cases, I'm seeing Access Denied error messages.

Once I've spun up the resource, do I need to do something additional to access it? I've got a Jupyter notebook on my local machine from which I'm trying to query entity search.


azure-cognitive-services
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.

1 Answer

romungi-MSFT avatar image
0 Votes"
romungi-MSFT answered ChrisDiehl-8801 commented

@ChrisDiehl-8801 Are you using the bing resource of Azure entity search? If Yes, then the subscription key of this resource with endpoint 'api.bing.microsoft.com' should work. Here is a working example to call with REST API.

 import http.client, urllib.parse
 import json
    
 subscriptionKey = '<your_key>'
 host = 'api.bing.microsoft.com'
 path = '/v7.0/search'
 mkt = 'en-US'
 query = 'italian restaurants near me'
    
 params = '?mkt=' + mkt + '&q=' + urllib.parse.quote (query)
    
 def get_suggestions ():
     headers = {'Ocp-Apim-Subscription-Key': subscriptionKey}
     conn = http.client.HTTPSConnection (host)
     conn.request ("GET", path + params, None, headers)
     response = conn.getresponse ()
     return response.read()
    
    
 result = get_suggestions ()
 print (json.dumps(json.loads(result), indent=4))

If you are using the key from the cognitive service resource of bing search with this endpoint then this error is possible. All bing search resources from cognitive services used a different endpoint and will error out.

· 1
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.

@romungi-MSFT I was using cognitive services. Let me step back and ask a higher level question. I'm trying to geolocate schools in the U.S. and am looking to gather results that I see in Bing Maps. I've noticed that when I enter the school names and known addresses in there, I see a structured result come back for the school which seems to suggest that an entity is defined for the school. I'm assuming entity search is what I want to gain access to that type of result. Which search service do I ultimately want to gain access to that type of result? Should I aim to use Bing Search or Azure Cognitive Search? Thanks for your help.

0 Votes 0 ·