0

Whenever I use getTasks() it returns Invalid Request

However when I use getTasksForProject it will return values.

getTasks()

$tasks = $asana_client->tasks->getTasks(["opt_fields" => "name,due_on"]);

foreach ($tasks as $task) {
    var_dump($task);//will return error
}

getTasksForProject

$tasks = $asana_client->tasks->getTasksForProject($projects[12]->gid, ["opt_fields" => "name,due_on"]);

foreach ($tasks as $task) {
    var_dump($task);    
}

object(stdClass)#312 (3) { ["gid"]=> string(16) "**8**3*31**73173" ["due_on"]=> string(10) "2020-06-26" ["name"]=> string(15) "Navbar Settings" }

What causes this error, under the documentation it does not say that a parameter for projectid is needed?

Shulz
  • 508
  • 3
  • 12
  • 27

1 Answers1

0

i try your code for project and works but the task script has a problem, i solved it like this:

my tasks function by workspace and asiggnee user gid:

public function getTasks($gid,$workspace,$client)
    {
        $tasks = $client->tasks->getTasks(array('workspace' => $workspace, 'assignee' => $gid), ["opt_fields" => "assignee,name,completed,start_on,due_on,completed_at,created_at,notes,parent,num_subtasks"]);
        return  $tasks;
    }

and i called like this:

$tasks=collect($this->getTasks($user->gid,$workspace[0]->gid,$asana_client))->sortByDesc('created_at');

Finally try the items retrieved like this: return dd($tasks);

PD: sorry by my bad endglish