Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Asana API + Zapier | Add a task to multiple projects via Batch API
// get taskName from the custom fields above
var taskID = inputData.taskID;
// add the task to multiple projects
// notes: https://forum.asana.com/t/add-a-task-to-multiple-projects-via-api/160035/7
let body = {
"data": {
"actions": [
{
"method": "POST",
"relative_path": "/tasks/" + taskID + "/addProject",
"data": {
"project": "123456" // FS:CRM project
}
},
{
"method": "POST",
"relative_path": "/tasks/" + taskID + "/addProject",
"data": {
"project": "78910" // FS:CRM 2 project
}
}
]
}
};
// utilize the Batch API
const res = await fetch('https://app.asana.com/api/1.0/batch', {
method: 'POST',
headers: {
'Authorization': 'Bearer 0/abc1234'
},
body: JSON.stringify(body)
});
const data = await res.json();
output = { data: data };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment