//native
/**
* Add Task to Section
* Move a task into a section of one of its projects (or add it to that project). Without insert_before/insert_after it goes to the top of the section.
*/
export async function main(
auth: RT.Asana,
section_gid: string,
task: string,
insert_before: string | undefined,
insert_after: string | undefined
) {
const response = await fetch(
`https://app.asana.com/api/1.0/sections/${section_gid}/addTask`,
{
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
data: {
task,
insert_before: insert_before || undefined,
insert_after: insert_after || undefined,
},
}),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 5 days ago