How create task with membership via API?

Hi @Ariel_Morelli,

You’re on the right track - to create a task in a section, you need to use the memberships property. My guess as to what’s going on here is that you’re getting caught by a very common area of confusion with our API that I’ve got a task to clarify in our documentation “someday hopefully soon”.

Our JSON payloads look different on reads vs. writes, which is something that catches pretty much everyone at some point or other. For memberships, if you were to see this on read:

"memberships": [
    { "project": {"id": 12345, "name": "MyProject"}, "section": {"id": 09876, "name":"My Section"} }
]

what you need to send on POST or PUT is

"memberships": [
    {"project": 12345, "section": 09876}
]

that is, the values for project and section are just the IDs, not objects with ID / name pairs.

One other thing that could cause that error is that in setting the membership, section is optional but project is always required. That error could be telling you that you only set the section property and are missing the project

The reason for this is what we call “multi-homing” - the ability of a task (including a section) to be in multiple projects. If this is the case, we need to know which project/section pair you’re working with in order to put everything in the right place.

Hopefully this helps!

4 Likes