I'm trying to create a task and then set a project on the task using nodejs and the asana thin wrapper available from npm.
var asana = require('asana');
var newTask = { name: "Your Mission", notes: "Stuff" };
var project = [{ id:321, name: "Missions Impossible"}];
var client = asana.Client.basicAuth('APIKEY');
client.tasks.createInWorkspace(123, newTask).then(function(task) {
client.tasks.addProject(task.id, project).then(function(o) {
// Check for empty object returned (sign of success)
if (Object.keys(o).length === 0)
console.log('yay!');
else
console.log('booo');
}
The task is created, but I get an error in the addProject method - "Possibly unhandled error. Invalid Request". I've tried different variations on the project object, but I'm out of ideas.
Is the project wrongly formed? Something else?