Creating a task using memberships is not working

I am trying to create a task and assign it to a section using the memberships property. The following code returns an error (the … following the gid indicate the removal of the actual value):

{
“data”: {
“resource_type”: “task”,
“name”: “Test of API Integration”,
“notes”: “API Test Notes”,
“resource_subtype”: “default_task”,
“assignee”: “1204303044…”,
“memberships”: [
{
“projects”: “12045168926…”,
“section”: “1204517290…”
}
]
}
}

JSON response:

{
“errors”: [
{
“message”: “You should specify one of workspace, parent, projects”,
“help”: “For more information on API status codes and how to handle them, read the docs on errors: Errors
}
]
}

Hi @Jim_Moline,

Are you making a call to our Create a task (POST /tasks) endpoint? If so you need to provide one of workspace, parent or projects in your request body in order for the request to succeed. Also, if you take a look at our documentation for request body for our Create a task (POST /tasks) endpoint (See BODY PARAMS section) we do not list memberships as an option in our request body.

If you want to create a task in a project and add it to a section I would suggest:

  1. Make a request to our Create a task (POST /tasks) endpoint and provide the project_gid in the projects request body params. So for example:
{
  "data": {
    "resource_type": "task",
    "name": "Test of API Integration",
    "notes": "API Test Notes",
    "resource_subtype": "default_task",
    "assignee": "1204303044",
    "projects": ["12045168926"]
  }
}
  1. Make a call to our Add task to section (POST /tasks/{section_gid}/addTask) endpoint and provide it with the task_gid of the task created in step #1

The above solves the error for the case of projects in the error message “You should specify one of workspace, parent, projects”

An example of fixing this error with workspace is:

{
  "data": {
    "resource_type": "task",
    "name": "Test of API Integration",
    "notes": "API Test Notes",
    "resource_subtype": "default_task",
    "assignee": "1204303044",
    "workspace": "<YOUR_WORKSPACE_GID>"
  }
}

Similarly with parent:

{
  "data": {
    "resource_type": "task",
    "name": "Test of API Integration",
    "notes": "API Test Notes",
    "resource_subtype": "default_task",
    "assignee": "1204303044",
    "parent": "<YOUR_TASK_GID>"
  }
}
1 Like

Thank you, @John_Vu . I was working off of some old posts that referenced it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.