Assigning section when using API to create new task

Can anyone provide some quick guidance on how to assign a particular project section to a new task that I’m creating with the API?

This is what I have so far, but I don’t see it specifically mentioned in the documentation how to specify a section within the project.

let body = {
  "data": {
    "assignee": "123456",
    "completed": false,
    "custom_fields": {
      "555555": "888888"
    },
    "due_on": "2021-09-30",
    "followers": [
      "987654"
    ],
    "name": "TASK NAME HERE",
    "notes": "Date Range: 9/25/2021 - 9/30/2021\n\nTotal Number of Days: 6",
    "projects": [
      "22446688"
    ],
    "resource_subtype": "default_task",
    "start_on": "2021-09-25",
    "workspace": "333222111"
  }
};

I figured it out by changing:

"projects": [
  "22446688"
],

With:

"memberships" : [ 
  {
    "project" : "22446688",
    "section" : "999444222666"
  }
]

Thanks to this post: Add task to a section upon creation via API request - #5 by Joe_Trollo

4 Likes

OK, now does anyone know how to do this for an existing task? I want to use the “Update a task” endpoint and be able to change/assign the task to an existing section ID.

Use the addProject endpoint for this. You’re allowed to specify a project that the task is already assigned to, in order just to move it into a particular section in that project.

1 Like