0
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
    # Request parameters
    'returnFaceId': 'true',
    'returnFaceLandmarks': 'false',
    'returnFaceAttributes': '{string}',
    'recognitionModel': 'recognition_01',
    'returnRecognitionModel': 'false',
})

try:
    conn =http.client.HTTPSConnection('southeastasia.api.cognitive.microsoft.com')
    conn.request("POST", "/face/v1.0/detect?%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 above code is not working.

I gave correct 1key1 value

I am getting:

[Errno 11002] getaddrinfo failed

Robert Dyjas
  • 4,979
  • 3
  • 19
  • 34
  • I suspect an issue with your proxy. Take a look at [this](https://stackoverflow.com/questions/35835767/urllib-error-urlerror-urlopen-error-errno-11002-getaddrinfo-failed) post. – cthrash Jun 07 '19 at 20:24
  • Can you please share the body that has been passed? – Ram Jun 10 '19 at 09:24
  • Thanks for responding. The issue was with permission issues in my office laptop. URL is responding well when I tried in personal laptop. But now I am getting "Invalid media type" error – Vidya Reddy Jun 11 '19 at 10:26

0 Answers0