Created
April 8, 2022 20:55
-
-
Save Garconis/054e0beea31e1702123d77c09b71d9fa to your computer and use it in GitHub Desktop.
Asana API + Zapier | Add a task to multiple projects via Batch API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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