Hit http url using python getting IOError
Question: I tried by hitting as below

    
    
    import urllib
    second_query="http://example.com"
    pw = urllib.urlopen(second_query)
    pw = pw.read()
    print pw
    

I am trying to hit jira api -<http://example.com> but I am getting following
error

    
    
    Traceback (most recent call last):
          File "abc.py", line 7, in <module>
            pw = urllib.urlopen(second_query)
          File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 87, in urlopen
            return opener.open(url)
          File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 203, in open
            return getattr(self, name)(url)
          File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 358, in open_http
            return self.http_error(url, fp, errcode, errmsg, headers)
          File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 371, in http_error
            result = method(url, fp, errcode, errmsg, headers)
          File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 683, in http_error_401
            errcode, errmsg, headers)
          File "/abc/xyz/pqr/thirdparty/python/2.6/lib/python2.6/urllib.py", line 381, in http_error_default
            raise IOError, ('http error', errcode, errmsg, headers)
        IOError: ('http error', 401, 'Unauthorized', <httplib.HTTPMessage instance at 0x138e26c8>)
    

Please suggest solution.


Answer: By reading the error it's clear that you don't have the required
authorization:

    
    
    IOError: ('http error', 401, 'Unauthorized', <httplib.HTTPMessage instance at 0x138e26c8>
    

You have somehow to provide the necessary credentials... I'm quite sure
however that Jira provides high level API to use its tools, so you don't have
to use a low level approach.

