<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Getting Basecamp API Working with Python</title>
	<atom:link href="http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/feed/" rel="self" type="application/rss+xml" />
	<link>http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/</link>
	<description></description>
	<lastBuildDate>Thu, 04 Mar 2010 11:43:30 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Benjamin Buch</title>
		<link>http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/comment-page-1/#comment-15206</link>
		<dc:creator>Benjamin Buch</dc:creator>
		<pubDate>Sun, 17 Jan 2010 09:36:44 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=359#comment-15206</guid>
		<description>I couldn&#039;t get this code running.&lt;br&gt;But I stumbled upon a working basecamp.py - it&#039;s part of the basecampreporting library (&lt;a href=&quot;http://github.com/cmheisel/basecampreporting/&quot; rel=&quot;nofollow&quot;&gt;http://github.com/cmheisel/basecampreporting/&lt;/a&gt;).&lt;br&gt;&lt;br&gt;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.&lt;br&gt;&lt;br&gt;This is how Chris Heisel did it (again around line 64):&lt;br&gt;&lt;br&gt;    def __init__(self, baseURL, username, password):&lt;br&gt;        self.baseURL = baseURL&lt;br&gt;        if self.baseURL[-1] == &#039;/&#039;:&lt;br&gt;            self.baseURL = self.baseURL[:-1]&lt;br&gt;&lt;br&gt;        self.opener = urllib2.build_opener()&lt;br&gt;&lt;br&gt;        self.auth_string = &#039;%s:%s&#039; % (username, password)&lt;br&gt;        self.encoded_auth_string = base64.encodestring(self.auth_string)&lt;br&gt;&lt;br&gt;        #Python 2.5, at least on Ubuntu is adding a newline when encoding,&lt;br&gt;        #which Basecamp chokes on and returns an HTTP 400&lt;br&gt;        self.encoded_auth_string = self.encoded_auth_string.replace(&#039;n&#039;, &#039;&#039;)&lt;br&gt;        self.headers = [&lt;br&gt;            (&#039;Content-Type&#039;, &#039;application/xml&#039;),&lt;br&gt;            (&#039;Accept&#039;, &#039;application/xml&#039;),&lt;br&gt;            (&#039;Authorization&#039;, &#039;Basic %s&#039; % self.encoded_auth_string), ]&lt;br&gt;        self.opener.addheaders = self.headers</description>
		<content:encoded><![CDATA[<p>I couldn&#39;t get this code running.<br />But I stumbled upon a working basecamp.py &#8211; it&#39;s part of the basecampreporting library (<a href="http://github.com/cmheisel/basecampreporting/" rel="nofollow">http://github.com/cmheisel/basecampreporting/</a>).</p>
<p>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.</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] == &#39;/&#39;:<br />            self.baseURL = self.baseURL[:-1]</p>
<p>        self.opener = urllib2.build_opener()</p>
<p>        self.auth_string = &#39;%s:%s&#39; % (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(&#39;n&#39;, &#39;&#39;)<br />        self.headers = [<br />            (&#39;Content-Type&#39;, &#39;application/xml&#39;),<br />            (&#39;Accept&#39;, &#39;application/xml&#39;),<br />            (&#39;Authorization&#39;, &#39;Basic %s&#39; % self.encoded_auth_string), ]<br />        self.opener.addheaders = self.headers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://codespatter.com/2009/04/01/getting-basecamp-api-working-with-python/comment-page-1/#comment-15201</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Tue, 03 Nov 2009 03:03:01 +0000</pubDate>
		<guid isPermaLink="false">http://codespatter.com/?p=359#comment-15201</guid>
		<description>Is this code still working for you?  I made your changes but basecamp dumps me into the login page now.</description>
		<content:encoded><![CDATA[<p>Is this code still working for you?  I made your changes but basecamp dumps me into the login page now.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
