0

I'm currently at my wits end right now in dealing with azure. I'm currently using (trying to) the package py-ms-cognitive specifically the bing websearch module. The documentation seems straightforward. "Sign up for MS azure account to get an API key to place here:"

>>> from py_ms_cognitive import PyMsCognitiveImageSearch
>>> search_term = "puppies"
>>> search_service = PyMsCognitiveImageSearch('API_KEY', search_term)
>>> first_fifty_result = search_service.search(limit=50, format='json') #1-50

I sign up for an azure account, and so far I'm kind of lost in which kind of API I need for this specific package my intuition (as well as others who are with me that are as lost as I am) tells me its a Cognitive services - Websearch API, I do that and bam two keys, I try both of them within this:

PyMsCognitiveImageSearch('API_KEY', search_term)

So far after running the debugger I continually get this response:

b'{ "error":{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription." }}'

I try creating a different project to see if that works, same thing, I've tried looking through these previously posted questions 'A' and 'B'. I've checked to see if my subscription location is the same as the API endpoints to which one is "global" with no option of changing it and the other set to my current region. I've tried using my sub ID, the generated APIs (both 1 and 2) and at this point anything that looks like an API key, all provide the same response. I'm not entirely sure what to do next because any other documentation I do find is either not relevant or entirely too abstract to be applicable. Any aid would be most appreciated.

Sebastian Goslin
  • 477
  • 1
  • 3
  • 22

1 Answers1

0

So here we go,

All cognitive services APIs now run on v7.0, where as the package I listed earlier runs on v5.0,

All you have to do is change one character in the source code and voila "black magic."

pull request for all who are curious

Change:

SEARCH_WEB_BASE = 'https://api.cognitive.microsoft.com/bing/v5.0/search'

to:

SEARCH_WEB_BASE = 'https://api.cognitive.microsoft.com/bing/v7.0/search'
Sebastian Goslin
  • 477
  • 1
  • 3
  • 22