Open angelapper opened 8 years ago
I can confirm this is an issue. Python 3.5.0
Full stack trace:
File "/project/insightly.py", line 352, in create
text = self.generateRequest(url, 'POST', data)
File "/project/insightly.py", line 593, in generateRequest
result = urllib2.urlopen(request, data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 162, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 463, in open
req = meth(req)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 1170, in do_request_
raise TypeError(msg)
TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.
[25/May/2016 15:18:30] "POST /api/registration/ HTTP/1.1" 500 157495
In my case I was calling insightly.create('contacts', contact)
.
contact = {
'last_name': 'NA',
'first_name': 'NA',
'tags': [{'TAG_NAME': 'web_signup'}],
'CONTACTINFOS': [{'LABEL': 'Work', 'DETAIL': 'test@test.com', 'TYPE': 'EMAIL', 'SUBTYPE': None}]
}
Any update on this?
Easy enough to fix. Add .enocde("utf-8") to data on line 596 of insightly.py, should be backwards compatible with 2.7, but someone with a 2.7 codebase should doublecheck.
Request Method: POST Request URL: http://localhost:8000/course-register-form/ Django Version: 1.8.4 Exception Type: TypeError Exception Value:
POST data should be bytes or an iterable of bytes. It cannot be of type str. Exception Location: C:\Users\angelapper\Anaconda3\envs\datalaushome\lib\urllib\request.py in dorequest, line 1170 Python Executable: C:\Users\angelapper\Anaconda3\envs\datalaushome\python.exe Python Version: 3.5.1