User Task Lists

Hi,

Background and Use Case

I am using Asana’s API to retrieve all tasks in an organization. I am using an enterprise level subscription with a service account for retrieving tasks. I am able to retrieve all tasks within projects in the organization, but I run into some issues with the private “My Tasks” lists.

Using Curl, I am able to retrieve tasks in the user task list using the service account, even if the tasks are private and have no project. However, I cannot retrieve these without the gid, which I am currently accessing though the browser. It appears there is no easy way to access these task lists through code.

My question

Is there an easy, efficient way to get all tasks in a project, including personal task lists?

Current Workaround

I believe this should work but I have yet to test it

  1. Enumerating each user in the organization, then getting their personal task lists.

  2. Enumerate each task in their personal tasks which is not already associated with a project in the organization.

  3. Continue with working strategy I am currently using:
    a. Enumerate all projects in organization
    b. Enumerate all tasks in each project

This strategy should avoid double counting any two tasks but still get all tasks. However, this is a very long, roundabout way of achieving this. Is there an easier way?

Thanks in advance,

Ani

Hi Ani,

When you say

are you referring to tasks or user task lists (UTLs) that you can’t retrieve; and are you referring to a UTL gid or task gid?

I’m trying to follow your description but need some clarification.

Hi Phil,

I am refering to UTLs that are called “My Tasks” in the UI.

Let me know if you need more clarification.

Ani

I don’t think there’s an easier way. I think the approach you describe would be the way to do it, I can’t think of a good alternative.

Thanks for you response. I will be sure to update this post if I find an easier way.

I think you mean, in an organization?

Let’s start there:
1 task can be assigned to 0 or 1 user, set to 0 or many projects, and 0 or many tags.

So, 1 task, can have 0 user / 0 project / 0 tags, or 1 user 3 projects 6 tags.

That said… from that endpoint:
https://developers.asana.com/docs/get-multiple-tasks
You can get tasks by user / by project / by tag.
If your task is set on 3 projects, you will retrieve it 3 times. + 1 if assigned to 1 user, + x if set to 1 or many tags.

Also, there’s more…
If 1 subtask is opened and set to a project / user / tag, that subtask will be retrieved when querying these endpoints.

Also, there’s the “floating” tasks, those who have 0 user / 0 project / 0 tags… that are absolutely impossible to get from that endpoint.

The solution is to use the “search” endpoint.

https://developers.asana.com/docs/search-tasks-in-a-workspace

Using that, you will never retrieve tasks multiple times.

You can query:
GET /workspaces/{workspace_gid}/tasks/search??is_subtask=false (or any other…).
The first time you download all tasks, use paging by blocs of 100, sorted by “?created_at”.

Then, query each next page using “=created_at.before=” (last modified date of the previous page).

Finally, store all these tasks somewhere on your server.

Then, next time you need to update your list, use the same endpoint,
but add the "?modified_at.after=yyyy-mm-ddThh:mm:ss (last time you run your script)

3 Likes

You are right, typo.

Thanks for the very detailed response. This seems to be the solution to my problem so I have marked it as such.

I have a just one more question:

You say to use pagination, in your explaination:

According to the link you provided, Search tasks in a workspace, the following is true about pagination when using the search.

Just to make sure I understand, in your explanation you sort by date, and as such you are not only able to use pagination, but you are also able to minimize time spent to get tasks by using a last modified date to only get recently added (or changed/deleted with a different search parameter) tasks. Is this correct?

It looks like this is a great way to considerably speed up the process, thank you. I will look into pagination as I am not currently using it, as well as implementing it in Java. I’ll update this thread if I have any more questions or just to let you know how it goes.

1 Like

I talked to them about paging in another thread, and the conclusion is that if you sort by “modified_at”, the results may be invalid because the modified_at date used is not the one from the task but the one of their index.
But, if you use “created_at” instead, it should be ok.

But, I did not try paging lots of data using that endpoint, we only use it to get the first 100 items for some very specific needs.

1 Like

What about tasks that were deleted or modified from the last date? I assume those wouldn’t show up under the “created_at” endpoint, but do correct me if I am mistaken. If they do not show, is there a workaround for getting the recently modifed/deleted tasks?

The first time you retrieve all, use “created_at”.

After, use “modified_at” to only query the last ones. But just remove a few hours to your query to make sure you have them all.

Also, if you use that method, you will never be notified of deleted tasks. You may need to re-query all from time to time I suppose.

Ok great! Thanks for all the info.

Hi Frederic,
The “search” end point works great. But it doesn’t work when we call it using a service account in an Asana Enterprise account. It seems the service account is not considered a premium user. Is there a way to solve this? Our goal is to enumerate all tasks in a project and we are doing it exactly as you suggested (using the created_at.before filter).
Thanks,
Arvind