gai error at /home [Errno -2] Name or service not known
Question: per the example in the httplib docs:

    
    
    >>> import httplib, urllib
    >>> params = urllib.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
    >>> headers = {"Content-type": "application/x-www-form-urlencoded",
    ...            "Accept": "text/plain"}
    >>> conn = httplib.HTTPConnection("bugs.python.org")
    >>> conn.request("POST", "", params, headers)
    >>> response = conn.getresponse()
    >>> print response.status, response.reason
    302 Found
    >>> data = response.read()
    >>> data
    'Redirecting to <a href="http://bugs.python.org/issue12524">http://bugs.python.org/issue12524</a>'
    >>> conn.close()
    

my code is:

    
    
    import httplib
    import urllib
    
    token = request.POST.get('token')
    if token:
        params = urllib.urlencode({'apiKey':'[some string]', 'token':token})
        connection = httplib.HTTPSConnection('rpxnow.com/api/v2/auth_info')
        connection.request('POST', "", params)
        response = connection.getresponse()
        print response.read()
    

inspection of my local vars yeilds:

connection: "httplib.HTTPSConnection instance at 0x8baa4ac" params:
'token=[some string]&apiKey=[some string]'

(My instructions to make this call are:

Use the token to make the auth_info API call: URL:
<https://rpxnow.com/api/v2/auth_info> Parameters:

apiKey [some string] token The token value you extracted above)

but I'm getting the error mentioned in the subject line. Why?


Answer: You've misunderstood the documentation to httplib. The parameter to
instantiate the `HTTPSConnection` is just the hostname. You then pass the
actual path as the second param to `request`. So:

    
    
    connection = httplib.HTTPSConnection('rpxnow.com')
    connection.request('POST', '/api/v2/auth_info', params)
    

