API Create Task with section membership via Wget or Http request

I can create a task like this
…api/1.0/tasks/projects=111111111111&notes=Something about the task&name=Name of task

But I cant figure out what the syntax should be for adding memberships

I would imagine it might be something like this
…api/1.0/tasks/memberships=[Projects:2222222,Sections:33333333]&projects=111111111111&notes=Something about the task&name=Name of task

Can someone give me an example of what it would look like? Basically as it would appear in a URL bar.

I already know I can create a task then add it to a section after, but why do two steps if I can do it in one.

Hi @Xavier,

You’re not going to be able to do this via URL query parameters (nor should you try). Creating a task is a POST request and the input parameters should be sent in the HttpRequest’s Body.

I haven’t tried this exact code snippet but I believe this is the syntax you’ll be wanting to use in the Body:

{
  "data": {
    "name": "Buy catnip",
    "memberships": [
      {
        "project": "12345"
        },
        "section": "12345"
        }
      }
    ],
    "notes": "Mittens really likes the stuff from Humboldt."
  }
}
1 Like

i think this json is valid

then the json is valid. however when i try this, i get an error message memberships: [1]: project: Missing required field

actually… although the above is valid json, this is what wound up working…

{
  "data": {
    "name": "Buy catnip",
    "memberships": [
      {
        "project": "12345"
        },
        "section": "12345"
        }
      }
    ],
    "notes": "Mittens really likes the stuff from Humboldt."
  }
}

Reply

9 MONTHS LATER

Barry_Cox

4m

i think this json is valid