Skip to content

Instantly share code, notes, and snippets.

@Garconis
Created April 27, 2023 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garconis/bcf6ec81814626f5a42c76f0056e7db0 to your computer and use it in GitHub Desktop.
Save Garconis/bcf6ec81814626f5a42c76f0056e7db0 to your computer and use it in GitHub Desktop.
Asana API + Zapier | Duplicate a task via API
// Duplicate the Asana FS:Audit task template that we made (note, it's not a "real" Task Template, but just a straggling task that sits in the project) and set the name based on the task name of the CRM task that got completed earlier.
// get taskName from the custom fields above
var taskTitle = inputData.taskName;
var taskID = "555555555"; // task to duplicate
// notes: https://forum.asana.com/t/now-available-project-and-task-duplication/49371
let body = {
"data": {
"include": [
"assignee",
"attachments",
"dependencies",
"followers",
"notes",
"projects",
"subtasks",
"tags"
],
// set the Task Name text value to be the this value from the above variable
"name": taskTitle
}
};
// find the task based on the taskID we set above
const res = await fetch('https://app.asana.com/api/1.0/tasks/' + taskID + '/duplicate', {
method: 'POST',
headers: {
'Authorization': 'Bearer 0/12345678'
},
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