Python Forum
Error in request, cache key - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Error in request, cache key (/thread-17207.html)



Error in request, cache key - a21250450 - Apr-02-2019

Error:
Traceback (most recent call last): File "/root/DNSaaS.py", line 497, in requestToken response, content = h.request(target.geturl(), 'POST', json.dumps(msgJson), headers) File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 2135, in request cachekey, File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1796, in _request conn, request_uri, method, body, headers File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1737, in _conn_request response = conn.getresponse() File "/usr/lib/python2.7/httplib.py", line 1108, in getresponse raise ResponseNotReady() ResponseNotReady
    def requestToken(self, user, password, tenant):
        """
        Method responsible ask for a token.

        :param user: User name
        :param password: Password
        :param tenant: Tenant name
        :rtype : object
        """
        headers = {
            'Accept': 'application/json',
            'Content-Type': 'application'
        }
        target = urlparse(self.__apiurlAAA)

        h = http.Http()
        msgJson = {"auth": {"tenantName": tenant, "passwordCredentials": {"username": user, "password": password}}}
        try:
            response, content = h.request(target.geturl(), 'POST', json.dumps(msgJson), headers)
        except:
            traceback.print_ex()
            return -1, "Server API not reachable,chega aqui "
        response_status = response.get("status")
        return response_status, content
Hello, someone can help me with these errors, I'm trying to make the orders with the postman?

Thanks


RE: Error in request, cache key - Larz60+ - Apr-02-2019

Sounds like you're trying to reuse request from a socket that's already closed.
python 'requests' (not urllib or httplib) will get you past this.
Is this legacy code?
which version of python?


RE: Error in request, cache key - a21250450 - Apr-02-2019

(Apr-02-2019, 09:25 AM)a21250450 Wrote:
Error:
Traceback (most recent call last): File "/root/DNSaaS.py", line 497, in requestToken response, content = h.request(target.geturl(), 'POST', json.dumps(msgJson), headers) File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 2135, in request cachekey, File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1796, in _request conn, request_uri, method, body, headers File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1737, in _conn_request response = conn.getresponse() File "/usr/lib/python2.7/httplib.py", line 1108, in getresponse raise ResponseNotReady() ResponseNotReady
Hello, someone can help me with these errors, I'm trying to make the orders with the postman?

Thanks