Comments on: Getting Basecamp API Working with Python http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/ Wed, 13 Mar 2013 20:51:33 +0000 http://wordpress.org/?v=2.8.4 hourly 1 By: » Basecamp Python Client http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/comment-page-1/#comment-15257 » Basecamp Python Client Wed, 15 Jun 2011 23:32:43 +0000 http://codespatter.com/?p=359#comment-15257 [...] Added also some suggestions from Greg Allard. [...] [...] Added also some suggestions from Greg Allard. [...]

]]>
By: Django App to connect to Basecamp API | Digital Trends & Technologies http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/comment-page-1/#comment-15254 Django App to connect to Basecamp API | Digital Trends & Technologies Wed, 08 Jun 2011 13:39:35 +0000 http://codespatter.com/?p=359#comment-15254 [...] Please note: Though that version has been updated to work with the current Basecamp API and Django 1.2 I did a fix from Greg Allard to rectify the basecamp.py wrapper. http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/ [...] [...] Please note: Though that version has been updated to work with the current Basecamp API and Django 1.2 I did a fix from Greg Allard to rectify the basecamp.py wrapper. http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/ [...]

]]>
By: Benjamin Buch http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/comment-page-1/#comment-15295 Benjamin Buch Sun, 17 Jan 2010 15:36:44 +0000 http://codespatter.com/?p=359#comment-15295 <p>I couldn't get this code running.<br>But I stumbled upon a working <a href="http://basecamp.py" rel="nofollow">basecamp.py</a> - it's part of the basecampreporting library (<a href="http://github.com/cmheisel/basecampreporting/)" rel="nofollow">http://github.com/cmheisel/bas...</a>.</p> <p>According to Chris Heisel, the author of basecampreporting, the reason why the original <a href="http://basecamp.py" rel="nofollow">basecamp.py</a> is not working properly is the use of base64. When you encode a string with base64, it adds a newline at the end of the encoded string. The newline is what irritates basecamp. Get rid of the newline, and <a href="http://basecamp.py" rel="nofollow">basecamp.py</a> works.</p> <p>This is how Chris Heisel did it (again around line 64):</p> <p> def __init__(self, baseURL, username, password):<br> self.baseURL = baseURL<br> if self.baseURL[-1] == '/':<br> self.baseURL = self.baseURL[:-1]</p> <p> self.opener = urllib2.build_opener()</p> <p> self.auth_string = '%s:%s' % (username, password)<br> self.encoded_auth_string = base64.encodestring(self.auth_string)</p> <p> #Python 2.5, at least on Ubuntu is adding a newline when encoding,<br> #which Basecamp chokes on and returns an HTTP 400<br> self.encoded_auth_string = self.encoded_auth_string.replace('n', '')<br> self.headers = [<br> ('Content-Type', 'application/xml'),<br> ('Accept', 'application/xml'),<br> ('Authorization', 'Basic %s' % self.encoded_auth_string), ]<br> self.opener.addheaders = self.headers</p> I couldn't get this code running.
But I stumbled upon a working basecamp.py – it's part of the basecampreporting library (http://github.com/cmheisel/bas....

According to Chris Heisel, the author of basecampreporting, the reason why the original basecamp.py is not working properly is the use of base64. When you encode a string with base64, it adds a newline at the end of the encoded string. The newline is what irritates basecamp. Get rid of the newline, and basecamp.py works.

This is how Chris Heisel did it (again around line 64):

def __init__(self, baseURL, username, password):
self.baseURL = baseURL
if self.baseURL[-1] == '/':
self.baseURL = self.baseURL[:-1]

self.opener = urllib2.build_opener()

self.auth_string = '%s:%s' % (username, password)
self.encoded_auth_string = base64.encodestring(self.auth_string)

#Python 2.5, at least on Ubuntu is adding a newline when encoding,
#which Basecamp chokes on and returns an HTTP 400
self.encoded_auth_string = self.encoded_auth_string.replace('n', '')
self.headers = [
('Content-Type', 'application/xml'),
('Accept', 'application/xml'),
('Authorization', 'Basic %s' % self.encoded_auth_string), ]
self.opener.addheaders = self.headers

]]>
By: Benjamin Buch http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/comment-page-1/#comment-15206 Benjamin Buch Sun, 17 Jan 2010 09:36:44 +0000 http://codespatter.com/?p=359#comment-15206 I couldn't get this code running.<br>But I stumbled upon a working basecamp.py - it's part of the basecampreporting library (<a href="http://github.com/cmheisel/basecampreporting/" rel="nofollow">http://github.com/cmheisel/basecampreporting/</a>).<br><br>According to Chris Heisel, the author of basecampreporting, the reason why the original basecamp.py is not working properly is the use of base64. When you encode a string with base64, it adds a newline at the end of the encoded string. The newline is what irritates basecamp. Get rid of the newline, and basecamp.py works.<br><br>This is how Chris Heisel did it (again around line 64):<br><br> def __init__(self, baseURL, username, password):<br> self.baseURL = baseURL<br> if self.baseURL[-1] == '/':<br> self.baseURL = self.baseURL[:-1]<br><br> self.opener = urllib2.build_opener()<br><br> self.auth_string = '%s:%s' % (username, password)<br> self.encoded_auth_string = base64.encodestring(self.auth_string)<br><br> #Python 2.5, at least on Ubuntu is adding a newline when encoding,<br> #which Basecamp chokes on and returns an HTTP 400<br> self.encoded_auth_string = self.encoded_auth_string.replace('n', '')<br> self.headers = [<br> ('Content-Type', 'application/xml'),<br> ('Accept', 'application/xml'),<br> ('Authorization', 'Basic %s' % self.encoded_auth_string), ]<br> self.opener.addheaders = self.headers I couldn't get this code running.
But I stumbled upon a working basecamp.py – it's part of the basecampreporting library (http://github.com/cmheisel/basecampreporting/).

According to Chris Heisel, the author of basecampreporting, the reason why the original basecamp.py is not working properly is the use of base64. When you encode a string with base64, it adds a newline at the end of the encoded string. The newline is what irritates basecamp. Get rid of the newline, and basecamp.py works.

This is how Chris Heisel did it (again around line 64):

def __init__(self, baseURL, username, password):
self.baseURL = baseURL
if self.baseURL[-1] == '/':
self.baseURL = self.baseURL[:-1]

self.opener = urllib2.build_opener()

self.auth_string = '%s:%s' % (username, password)
self.encoded_auth_string = base64.encodestring(self.auth_string)

#Python 2.5, at least on Ubuntu is adding a newline when encoding,
#which Basecamp chokes on and returns an HTTP 400
self.encoded_auth_string = self.encoded_auth_string.replace('n', '')
self.headers = [
('Content-Type', 'application/xml'),
('Accept', 'application/xml'),
('Authorization', 'Basic %s' % self.encoded_auth_string), ]
self.opener.addheaders = self.headers

]]>
By: Greg http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/comment-page-1/#comment-15201 Greg Tue, 03 Nov 2009 03:03:01 +0000 http://codespatter.com/?p=359#comment-15201 Is this code still working for you? I made your changes but basecamp dumps me into the login page now. Is this code still working for you? I made your changes but basecamp dumps me into the login page now.

]]>