Skip to content

Instantly share code, notes, and snippets.

@ikbelkirasan
Last active June 17, 2021 12:52
Show Gist options
  • Save ikbelkirasan/681e26f17f5a2492ea6833e957fff379 to your computer and use it in GitHub Desktop.
Save ikbelkirasan/681e26f17f5a2492ea6833e957fff379 to your computer and use it in GitHub Desktop.
Duplicate project in Asana via Zapier Code step
const { projectId, teamId, newProjectName, accessToken } = inputData;
const payload = {
data: {
name: newProjectName,
team: teamId,
include: [
"members",
"notes",
"task_notes",
"task_subtasks",
"task_attachments",
"task_dependencies",
"task_followers",
],
},
};
const response = await fetch(
`https://app.asana.com/api/1.0/projects/${projectId}/duplicate`,
{
method: "POST",
body: JSON.stringify(payload),
headers: {
authorization: `Bearer ${accessToken}`,
},
}
);
const data = await response.json();
if (!response.ok) {
let errorMessage = `[${response.status}] `;
errorMessage += data.errors
.map((error) => [error.message, error.help].filter(Boolean).join(" "))
.join("\n");
throw new Error(errorMessage);
}
return {
data,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment