Click here to Skip to main content
13,897,154 members
Click here to Skip to main content
Add your own
alternative version


16 bookmarked
Posted 8 Dec 2006

Access Basecamp Through .NET API Wrapper

, 8 Dec 2006
Rate this:
Please Sign up or sign in to vote.
This API will make submission to Basecamp easier by converting returned responses into .NET objects.


This wrapper simplifies calls to the Basecamp API by returning .NET objects.

How I Built It

  1. First, I created a class for each response type returned by the Basecamp API.

    • AbbreviatedPost
    • AttachmentCategory
    • Comment
    • Category
    • Milestone
    • Person
    • Post
    • PostCategory
    • Project
    • TodoItem
    • TodoList

    Each of these classes then provided a static method that can parse an XML response into a generic list of that type.

    public static IList<Project> Parse(XmlNodeList projectNodes)

  2. Next, I created the BasecampManager class that would do the work to format the request, parse the response, and return the desired object.

    public IList < Project > GetProjects() 
        string cmd = "/project/list"; 
        IList<Project> projects = null;
        if (IsInitialized())
            XmlDocument xml = SendRequest(cmd, "");
            projects = Project.Parse(xml.SelectNodes("//project"));
        return projects;
  3. Next, I needed to handle requests that required an input request XML string.

    I accomplished this, by adding another static method to the specific domain classes that could generate an XML request string from an incoming set of parameters.

    public static string CreateCommentRequest(int postID, string body)
        System.IO.StringWriter sw = new System.IO.StringWriter();
        XmlWriter w = new XmlTextWriter(sw);
        w.WriteEndElement(); //end postID
        w.WriteEndElement(); //end body
        w.WriteEndElement(); //end comment
        w.WriteEndElement(); //end request
        return sw.ToString();

    I called this method then from my BasecampManager when I needed to create a Basecamp comment:

    public Comment CreateComment(int projectID, int postID, string body)
        string cmd = "/msg/create_comment";
        string request = Comment.CreateCommentRequest(postID, body);
        XmlDocument xml = SendRequest(cmd, request);
        Comment comment = null;
        IList<Comment> comments = 
        if (comments.Count > 0)
            comment = comments[0];
        return comment;

  4. I then repeated this process for each request/response that I wished to implement.

How To Use It

Step 1) Initialize connection information

Option 1: Use an application configuration file

  • basecamp_projectURL: project URL excluding the HTTP/HTTPS prefix
  • basecamp_userName/basecamp_password: user/password that has access to the desired project
  • basecamp_secureMode: true if using HTTPS, false otherwise

    BasecampManager b = new BasecampManager();

Option 2: Set connection details at construction

BasecampManager b = new BasecampManager(url, username, pwd, secure);

Option 3: Override configuration values

BasecampManager b = new BasecampManager();
b.Url = "";
b.Username = "myusername";
b.Password = "mypassword";
b.SecureMode = false;

Step 2) Call Methods to Retrieve/Update Data

IList <Project> projects = b.GetProjects();

That's it! Have fun investigating and using the other methods I wrapped. I hope you find this very simple and hopefully useful.

What I Didn't Do and What You Might Want To Improve

  • There are a couple places in the Basecamp API that different responses contain slightly different object signatures. For example: Company is returned differently when contained in a project than when selecting a list of companies. I created a couple constructors that take this into account, but may have missed some of the finer points on this one.
  • There are also some attributes that don't get passed depending on the requestor's permission level. For now, I only wrap these in a try/catch that swallows any exceptions. Person.Parse is a good example of this.
  • I had some DateTime variables that I had to set to 1/1/1900 instead of null. Person.Parse is a good example of this.
  • I did not implement time-tracking or some of the modify (update/add/delete) for all methods.
  • While I tested the methods, I found that updating/deleting comments was not working. I'm not sure if this was me, or something with the Basecamp API.
  • You may find that your Basecamp data causes unhandled exceptions when trying to load the .NET objects since you may have data in your projects that I do not and did not test.


I must give credit for the beginning implementation of BasecampManager. I used the API I found by Munsifali Rashid at I modified it slightly according to a post on the Basecamp forum:

webRequest.ServicePoint.Expect100Continue = false;


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    QuestionHow to download files which are uploaded today from all projects Pin
    nirajzambad12-Feb-14 3:42
    membernirajzambad12-Feb-14 3:42 
    I want to download files which are uploaded today,from a project?
    Please tell me how could i do that?
    Questionthe remote server returned an error (500) internal server error Pin
    nirajzambad22-Jan-14 22:50
    membernirajzambad22-Jan-14 22:50 
    AnswerRe: the remote server returned an error (500) internal server error Pin
    Niteen Jadhav26-Feb-14 3:23
    memberNiteen Jadhav26-Feb-14 3:23 
    Questionserver forbidden error while getting the response Pin
    dharamveer pal27-Feb-13 2:01
    memberdharamveer pal27-Feb-13 2:01 
    Questionserver forbidden error while getting the response Pin
    dharamveer pal27-Feb-13 2:00
    memberdharamveer pal27-Feb-13 2:00 
    QuestionAbout basecamp command. Pin
    baiju@ispg.in6-Feb-13 19:08
    memberbaiju@ispg.in6-Feb-13 19:08 
    GeneralSearch documents Pin
    CurtWRC31-Mar-10 4:44
    memberCurtWRC31-Mar-10 4:44 
    GeneralNice work and a Little bug Pin
    Member 15589429-Jul-09 11:23
    memberMember 15589429-Jul-09 11:23 
    GeneralRe: Nice work and a Little bug Pin
    JoeSox28-May-10 6:48
    memberJoeSox28-May-10 6:48 
    GeneralWorks well, how can i contribute adaptation to VS2008 Pin
    michael kariv24-Sep-08 9:06
    membermichael kariv24-Sep-08 9:06 
    GeneralThanks - working great Pin
    Ryan Farley17-Mar-08 18:52
    memberRyan Farley17-Mar-08 18:52 
    GeneralHaving trouble using the API Pin
    Amhed Herrera4-Jun-07 13:48
    memberAmhed Herrera4-Jun-07 13:48 
    GeneralBug in TodoItem.cs Pin
    dave@davefrank.com9-Jan-07 6:29
    memberdave@davefrank.com9-Jan-07 6:29 
    GeneralCannot send a content-body with this verb-type. Pin
    johnstrait114-Dec-06 10:17
    memberjohnstrait114-Dec-06 10:17 
    GeneralRe: Cannot send a content-body with this verb-type. Pin
    Loyll2129-Dec-06 8:30
    memberLoyll2129-Dec-06 8:30 
    GeneralRe: Cannot send a content-body with this verb-type. Pin
    CurtWRC31-Mar-10 4:40
    memberCurtWRC31-Mar-10 4:40 
    GeneralRe: Cannot send a content-body with this verb-type. Pin
    Member 803094623-Jun-11 9:16
    memberMember 803094623-Jun-11 9:16 
    GeneralRe: Cannot send a content-body with this verb-type. Pin
    guideX22-Mar-12 14:02
    memberguideX22-Mar-12 14:02 
    GeneralRe: Cannot send a content-body with this verb-type. Pin
    guideX22-Mar-12 15:55
    memberguideX22-Mar-12 15:55 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
    Web05 | 2.8.190306.1 | Last Updated 8 Dec 2006
    Article Copyright 2006 by binaryace
    Everything else Copyright © CodeProject, 1999-2019
    Layout: fixed | fluid