Unable to createTask to a section (JavaScript)

I try to create an array of tasks and then to create this under the respective section, but every time I get a Invalid request. However, when I do so using the .tasks.createInWorkspace(XXXXXX, taskAsana [i]) or the .tasks.createTask(taskAsana [i]) it works and creates a new task in the project. Although when I try to do so for a particular section… it doesnt seem to work.

var taskAsana = new Array();

function x(ass, t) {
var x = {assignee: ass, name: t, project: [“XXXXXXXXXX”]};
taskAsana.push(x);
}

while (i < taskAsana.length) {
client.sections.addTask(XXXXXXXX, taskAsana[i]);
}

Hi,

Could you use backquotes to highlight your code please? That is a bit hard to read, mixed up with text.

Thanks!

Hi,
Thanks for the response, my apologies.

I try to create an array of tasks and then to create this under the respective section, but every time I get a Invalid request. However, when I do so using the .tasks.createInWorkspace(XXXXXX, taskAsana [i]) or the .tasks.createTask(taskAsana [i]) it works and creates a new task in the project. Although when I try to do so for a particular section… it doesnt seem to work.

var taskAsana = new Array();

function x(ass, t) { var x = {assignee: ass, name: t, project: [“XXXXXXXXXX”]}; taskAsana.push(x); }

while (i < taskAsana.length) { client.sections.addTask(XXXXXXXX, taskAsana[i]); }

If I am not mistaken, you need to create the task and then move it to a section. @Phil_Seeman did I dream this?!

You should be able to get the new task into a project and section by specifying the memberships property instead of the project property. Here’s an example of the format of that property:

Thanks!