More options to get tasks from API

Hi there!

You should be able to ask for more than the id and name with the “fields” parameter in the first GET request, something like this curl example:

curl --header "Authorization: Bearer $ASANA_PERSONAL_ACCESS_TOKEN" \
"https://app.asana.com/api/1.0/tasks?assignee=me&limit=100&workspace=$WORKSPACE_ID&opt_fields=name%2Cassignee_status"

With our php client library that ends up looking something like the following example:

<?php
require dirname(__FILE__) . '/vendor/autoload.php';  // This is using Composer for dependencies
use Asana\Client;
$ASANA_PERSONAL_ACCESS_TOKEN = getenv('ASANA_PERSONAL_ACCESS_TOKEN'); // Get my access token from the shell environment

$client = Asana\Client::accessToken($ASANA_PERSONAL_ACCESS_TOKEN);
$taskIterator = $client->tasks->findAll(array('workspace'=>getenv('ASANA_WORKSPACE_ID'), 'assignee'=>'me'),
  array('fields'=>array('name', 'assignee_status'), 'item_limit'=>10)
);

foreach ($taskIterator as $index => $task) {
  var_dump($task);
}
4 Likes