client.sections.add_task_for_section not working with/without membership

Hi, I am trying to create tasks directly in a given section using the API and Python Library but cannot get rid of this ‘Missing Input’ error.

I have found multiple forum threads detailing that the membership for project and section need to be defined to add a task to a specific section, however I cannot get the command to work with or without membership defined.

The testSection and testProject variables have been tested with other commands (can get both and add new tasks to the project) and are correct GID values. testGID is a manually set new GID value for the new task, however I have tried the command letting Asana set a new GID automatically and that did not work either.

What am I missing here or is there another set of commands I can use to achieve this same result? the code line in question and command line results are pasted below. Thank you.

result1 = client.sections.add_task_for_section(testSection, {‘gid’: testGID, ‘name’: ‘testTask1’, ‘memberships’: [{‘project’: testProject, ‘section’: testSection}]}, opt_pretty=True)

Traceback (most recent call last):
File “AsanaTest.py”, line 46, in
result1 = client.sections.add_task_for_section(testSection, {‘gid’: testGID, ‘name’: ‘testTask1’, ‘memberships’: [{‘project’: testProject, ‘section’: testSection}]}, opt_pretty=True)
File “C:\Python27\lib\site-packages\asana\resources\gen\sections.py”, line 19, in add_task_for_section
return self.client.post(path, params, **options)
File “C:\Python27\lib\site-packages\asana\client.py”, line 200, in post
return self.request(‘post’, path, data=body, headers=headers, **options)
File “C:\Python27\lib\site-packages\asana\client.py”, line 89, in request
raise STATUS_MAPresponse.status_code
asana.error.InvalidRequestError: Invalid Request: task: Missing input

@Phil_Seeman isn’t it something like: you can’t create directly in a section but rather need to move it after? :thinking:

Hey I actually figured it out by going into sections.py and getting the proper formatting from there. I had created a new task which went into the first section and this code was to move it to a new section.

The correct code with a created task ‘testTask’ is:

result2 = client.sections.add_task(testSection, {‘data’: testTask, ‘task’: taskGID}, opt_pretty=True)

Updating as closed.

1 Like