I don’t know PHP, but can you see the details of the InvalidRequestError? That might tell you the specific reasons.
If you get the error at getTask(), please check if you have specified the container of the task, such as project, tag, or a pair of workspace and assignee.
I do see you are using getTasks() so it seems you trying to get information for all tasks under a project. Here is what I did to get all tasks under a project.
<?php
require 'vendor/autoload.php';
$client = Asana\Client::accessToken(''INSERT ACCESS TOKEN HERE');
$project_id = 'XXXXXXXXXXXXXXX'; // Insert project Id you want to pull tasks from
$tasks = $client->tasks->getTasksForProject($project_id);
foreach($tasks as $task) {
echo $task->name . ": " . $task->gid . "<br>";
}
I have gone through the Asana documentation with regards to getTasks() and see it allows you to add filters. This is probably the reason you want to use it this way. Here is my example using getTasks()
<?php
require 'vendor/autoload.php';
$client = Asana\Client::accessToken('INSERT ACCESS TOKEN HERE');
$getTasks = [
// Below are the filters, only use 1. For more filters go to https://developers.asana.com/docs/get-multiple-tasks
//'project' => 'xxxxxxxxxxxxxxx' // Insert your project ID
//'section' => 'xxxxxxxxxxxxxxx' // Or insert your section ID
];
$tasks = $client->tasks->getTasks($getTasks);
foreach($tasks as $task){
echo $task->name . ": " . $task->gid . "<br>";
}
Please remember to use one filter at a time as it will push out an error unless you using a filter such as the workspace filter then you must also specify the assignee to filter on. More on this in Asana’s documentation