I'm quite desperate for some help as I've been trying and failing for days :( I am using the PYTHON code sample provided in the MS CV documentation. Here is my code:
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '****************************',
}
params = urllib.parse.urlencode({
# Request parameters
'visualFeatures': 'Categories',
#'details': 'Celebrities',
'language': 'en',
})
try:
body = {"url":"https://www.doghealth.com/images/can_dogs_eat_strawberries.jpg"}
conn = http.client.HTTPSConnection('westeurope.api.cognitive.microsoft.com')
conn.request("POST", "/vision/v3.2-preview.3/analyze?%s" % params, "{body}" , headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
The error is:
TypeError Traceback (most recent call last)
<ipython-input-60-f0f928148ac1> in <module>
21 conn = http.client.HTTPSConnection('westeurope.api.cognitive.microsoft.com')
---> 22 conn.request("POST", "/vision/v2.1/analyze?visualFeatures=Description,Tags&details=Celebrities&language=en" % params, "{body}" , headers)
23 response = conn.getresponse()
**TypeError: not all arguments converted during string formatting**
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-60-f0f928148ac1> in <module>
26 conn.close()
27 except Exception as e:
---> 28 print("[Errno {0}] {1}".format(e.errno, e.strerror))
29
30 ####################################
AttributeError: 'TypeError' object has no attribute 'errno'
Please help if you can, I don't know where I'm going wrong. Thank you