I am a bit surprised you are passing an array, I would expect addSubtask to take an object instead with key-value pairs, but maybe that’s how PHP works.
Anyway, the answer invalid request always has details about what’s the issue. Can you share it here?
It looks like you are trying to add a subtask to your demo task!
For this I use the createSubtaskForTask() function.
//Notes: I have to pass in the user because I am running this as a job.
//You should be able to scrap everything untill ->tasks and put your bit infront
//for you it should be
$client->tasks->createSubtaskForTask($task->gid, ['name' => 'name', 'notes' => 'description'])
AsanaController::getClient($this->user)->tasks->createSubtaskforTask(
$this->task,//Note, This it the Task GID
[
'name' => $this->name,
'notes' => $this->notes,
'resource_subtype' => $this->subtype,
]
);
This is code from my little application… And it works. I am working with Laravel and the code is from a job to run in the background. So I am using $this->var These are just values I get from the form somewhere else/ Just replaces them with what you want it to be… Or scrap those you dont want, You can add the same fields to the array as you can on createTask