Skip to content

Instantly share code, notes, and snippets.

@joefusaro
Created August 26, 2016 05:23
Show Gist options
  • Save joefusaro/f3297c253beb6bba93e075d8b8da9822 to your computer and use it in GitHub Desktop.
Save joefusaro/f3297c253beb6bba93e075d8b8da9822 to your computer and use it in GitHub Desktop.
In [10]: out = requests.post('https://na1.salesforce.com/services/Soap/c/10.0', data=xml, headers=headers)
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/sessions.py:443: FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.
data = data or {},
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-10-6dcb74795d5a> in <module>()
----> 1 out = requests.post('https://na1.salesforce.com/services/Soap/c/10.0', data=xml, headers=headers)
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/api.pyc in post(url, data, json, **kwargs)
106 """
107
--> 108 return request('post', url, data=data, json=json, **kwargs)
109
110
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/api.pyc in request(method, url, **kwargs)
48
49 session = sessions.Session()
---> 50 response = session.request(method=method, url=url, **kwargs)
51 # By explicitly closing the session, we avoid leaving sockets open which
52 # can trigger a ResourceWarning in some cases, and look like a memory leak
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/sessions.pyc in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
462 }
463 send_kwargs.update(settings)
--> 464 resp = self.send(prep, **send_kwargs)
465
466 return resp
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/sessions.pyc in send(self, request, **kwargs)
574
575 # Send the request
--> 576 r = adapter.send(request, **kwargs)
577
578 # Total elapsed time of the request (approximately)
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/adapters.pyc in send(self, request, stream, timeout, verify, cert, proxies)
368 decode_content=False,
369 retries=self.max_retries,
--> 370 timeout=timeout
371 )
372
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.pyc in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, **response_kw)
542 httplib_response = self._make_request(conn, method, url,
543 timeout=timeout_obj,
--> 544 body=body, headers=headers)
545
546 # If we're going to release the connection in ``finally:``, then
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.pyc in _make_request(self, conn, method, url, timeout, **httplib_request_kw)
347 # conn.request() calls httplib.*.request, not the method in
348 # urllib3.request. It also calls makefile (recv) on the socket.
--> 349 conn.request(method, url, **httplib_request_kw)
350
351 # Reset the timeout for the recv() on the socket
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in request(self, method, url, body, headers)
1051 def request(self, method, url, body=None, headers={}):
1052 """Send a complete request to the server."""
-> 1053 self._send_request(method, url, body, headers)
1054
1055 def _set_content_length(self, body, method):
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in _send_request(self, method, url, body, headers)
1091 for hdr, value in headers.iteritems():
1092 self.putheader(hdr, value)
-> 1093 self.endheaders(body)
1094
1095 def getresponse(self, buffering=False):
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in endheaders(self, message_body)
1047 else:
1048 raise CannotSendHeader()
-> 1049 self._send_output(message_body)
1050
1051 def request(self, method, url, body=None, headers={}):
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in _send_output(self, message_body)
895 #message_body was not a string (i.e. it is a file) and
896 #we must run the risk of Nagle
--> 897 self.send(message_body)
898
899 def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.pyc in send(self, data)
867 datablock = data.read(blocksize)
868 else:
--> 869 self.sock.sendall(data)
870
871 def _output(self, s):
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.pyc in sendall(self, data)
223 def sendall(self, data):
224 while len(data):
--> 225 sent = self._send_until_done(data)
226 data = data[sent:]
227
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.pyc in _send_until_done(self, data)
213 while True:
214 try:
--> 215 return self.connection.send(data)
216 except OpenSSL.SSL.WantWriteError:
217 _, wlist, _ = select.select([], [self.socket], [],
/Users/joefusaro/perry/venv/lib/python2.7/site-packages/OpenSSL/SSL.pyc in send(self, buf, flags)
1266 buf = str(buf)
1267 if not isinstance(buf, bytes):
-> 1268 raise TypeError("data must be a memoryview, buffer or byte string")
1269
1270 result = _lib.SSL_write(self._ssl, buf, len(buf))
TypeError: data must be a memoryview, buffer or byte string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment