Question

i am currently working on a simple api call to basecamp i have managed to set up:

  • New project
  • todo list
  • todo items for the list

Currently i'm completing this through a php wrapper for the api (can be found here https://github.com/bdunlap/basecamp.php) and a foreach loop. But it takes ages and i doubt this is the best way to accomplish this.

My question: is it possible to add multiple todo items at once?? i would ideally like to add 20ish items. The documentation on github only states adding a single item (https://github.com/basecamp/bcx-api/blob/master/sections/todos.md#create-todo) i have tried a nested array but had no luck.

code i have used is below

/*** Create a new todo list:*/
$todolist =array('name' => 'Post Project', 'description' => 'Things to complete after project is completed');   
$ProjectToDoList = $basecamp('POST', '/projects/'.$newProject->id.'/todolists.json', $todolist);
echo "Post Project Todo List ID is {$ProjectToDoList->id}\n";

/*** just incase i want to add due dates in the future *****/
//array('content' => '3 month review contact client'),
/*** just incase i want to add due dates in the future *****/

/*** Add todo items to the Post Project list ****/ 
$todoItems = array( 
    array('content' => 'User guide supplied'),
    array('content' => 'Client Training Completed'),
    array('content' => '3 month review contact client'),
    array('content' => 'Add to mailchimp mailing list and set up auto responder')   
);
foreach($todoItems as $todoItem){
    $ToDoListItem = $basecamp('POST', '/projects/'.$newProject->id.'/todolists/'.$ProjectToDoList->id.'/todos.json', $todoItem);
}
Was it helpful?

Solution

It isn't possible to add multiple todos within a single request. You'll want to make an individual POST request for each todo. Providing you keep within our rate limits (https://github.com/basecamp/bcx-api#rate-limiting) everything should be a-ok :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top