API Tasks giving me empty response

Hi,

I’ve been developing a small tool to assist in some small tasks to streamline how we work with them. The PHP library has been giving me something that I can’t seem to figure out.

Workspaces/Login/User info can be fetched. No problemo. I can get a taskcount also. However, when I try to fetch an actual set of Tasks it will not return any results. Moreover, the explorer will return the desired set.

  • I’ve tried swapping a personal access token to oAuth, no difference.
  • I’ve tried taking out as many fields/args to that call but no results.
  • Taking out the limit or aiming for a smaller set
// Call to fetch tasks
$this->asanaClient->tasks->getTasksForProject(
    $currentProjectGid,
    [
        'project_gid'     => $currentProjectGid,
        'limit'           => self::DEFAULT_LIMIT, // 100
        'opt_fields'      => implode(
            ',',
            [
                'gid',
                'resource_type',
                'name',
            ]
        ),
    ]
);

Anyone some ideas? Do I need to set some permissions or something? I really don’t get it :slight_smile:

You don’t have any error given back? If you put the result in a variable and log it, what’s inside?

In my opinion, no need to pass the project gid twice, the first param of getTasksForProject should be enough.

That was me just trying out :slight_smile: I don’t get any error given back. I actually get an empty pagination object back. Same parameters in Api Explorer will give results.

To give a better understanding, this is what I’m seeing. That project definitely has tasks in there. I’ve attached some pictures to proof. Would be great if anyone of the Asana team could chime in.

New users are only allowed one attachment. I could’ve merged my photo if I knew that. Here comes what I see in the PHP API.

Screenshot_2022-08-29_21-51-57

Fetching a single task did work… :thinking:

Tried to follow this thread:

picking just one arg didn’t seem to work for me.

Using version 0.10.8 of the PHP library.

Found it.

While going through the options I found the iterator_type. When I changed it to false it gave me back results. It seems like, but this is a wild guess – without diving deeper to be honest because the docs are badly documentated and nearly half the code is left unhinted making it difficult to read and having to step through to make sense… – that the ItemIterator is not interfacing correctly with CollectionPageIterator to trigger the protected function getNext() that actually performs the $client->get() call.

If you change iterator_type to false, then it will straight up request the call without the Collection class.

2 Likes