JSFiddle - React, Tailwind, and code Playground
by Jon Fuller
JavaScript
// get taskName from the custom fields above
var taskTitle = inputData.taskName;
var taskID = "496982620327584";
// notes: https://developers.asana.com/docs/duplicate-a-task
let body = {
"data": {
"include": [
"notes",
"assignee",
"subtasks",
"attachments",
"tags",
"followers",
"projects",
"dates",
"dependencies",
"parent"
],
// set the Task Name text value to be the this value from the above variable
"name": taskTitle
}
};
// find the task based on the taskID
const res = await fetch('https://app.asana.com/api/1.0/tasks/' + taskID + '/duplicate', {
method: 'POST',
headers: {
'Authorization': 'Bearer 0/896ba46e9e5b2e23cb80ff243939c37d'
},
body: JSON.stringify(body)
});
const data = await res.json();
output = {data: data};