Cannot create task with memberships via API

Hey, I’m trying to create a task using node asana API.

Everything works great if I’m specifying only projects: projectId, but I need also specify the section, so my code is “memberships”: [
{“project”: 12345, “section”: 09876}
]

And I always getting this error: Error: Invalid Request

I think you must do 2 requests, first create your task in the project, then add task to the section.
You don’t set the section of the task, you add the task to the section, as described there:

According to this threads it’s possible to set the section on creation.
https://forum.asana.com/t/how-create-task-with-membership-via-api/10481/2https://forum.asana.com/t/add-task-to-a-section-upon-creation-via-api-request/51957/5

Also as I understand from here Build an app with Asana , I can specify section on creation.

1 Like

I just tried it in our app to see how we do this :smiley: and I found that we also pass the “projects” parameter. So, the post looks like:

{“data”:{“name”:“14h19”,“projects”:“123456”,“memberships”:[{“project”:“123456”,“section”:“456789”}]}}

But, when I tried without the “projects” parameter, I got a 400 bad request response, but in the response info, I got informations about what is going wrong:

“message=You should specify one of workspace, parent, projects”

So, you should look at the “body” of non-200 responses, sometimes they give informations about why it doesn’t work.

2 Likes

Wow Frederic, thanks a lot, it works, you really helped me.

1 Like