Bulk import tickets into CodeBaseHQ from CSV file

Neil's picture
Neil
20 Nov 2011

Here at C&W we've used CodeBaseHQ since day one for task tracking, time tracking, bug tracking and hosted version control. It's a great product, they've recently released their v4 version of the app which is even nicer to use.

During project kickoff we will typically create a specification in a spreadsheet which details each feature as a user story or task description. As a result, there is typically a very boring task of copying and pasting the tasks into CBHQ so we can track them.

My weekend project this weekend was to use the CBHQ API to import the tickets from a CSV file. The results of this are in the zip at the bottom of the post. The whole thing works really well. I have some plans to create something a bit more interactive allowing you to select the project from a drop down (populated form the API). However, if you stick with the CSV format, and don't mind editing the php script, this will do the job nicely.

The script works by converting the CSV into an multi-dimensional array and then this is converted into a series of XML objects which are posted to the API URL.

PHP array

<?php
   
[0]=>
      array(
7) {
        [
"summary"]=>
       
string(14) "my test task 1"
       
["status-id"]=>
       
string(1) "1"
       
["reporter-id"]=>
       
string(4) "123"
       
["assignee-id"]=>
       
string(5) "123"
       
["priority-id"]=>
       
string(1) "1"
       
["ticket-type"]=>
       
string(4) "task"
       
["milestone-id"]=>
       
string(5) "24342"
           
["estimated-time"]=>
       
string(2) "33"
     
}   
?>

XML

<?php
<ticket>
  <
summary>my test task 2</summary>
  <
status-id>1</status-id>
  <
reporter-id>123</reporter-id>
  <
assignee-id>123</assignee-id>
  <
priority-id>1</priority-id>
  <
ticket-type>Task</ticket-type>
  <
milestone-id>24342</milestone-id>
  <
estimated-time>163</estimated-time>
</
ticket>
?>

It's worth noting CBHQ have a rate limit of 80 posts per hour and each ticket needs to be done as a seperate post, so if you have hundreds of tickets to import you might want to contact CBHQ to up your limit.

AttachmentSize
cbhq_importer.zip21.46 KB

Find out how Cameron & Wilding can help your business on the webContact us