Pulling the Task ID using the API where the Task is unassigned

users
api

#1

Hi,

So I am working on pulling all of the users and the tasks that they are assigned to. I was wondering using the api, how do I get all unassigned tasks? Is there a special unassigned id?

I would really like to use this type of link https://app.asana.com/api/1.0/tasks?assignee=[unassigned]&workspace=[workplaceid]

Any help would be great thanks!


#3

Hey @wtadmin,

Are you trying to pull every unassigned task in your workspace? If so, that is going to be a lot of data. I recommend narrowing the scope of what you’re trying to pull if possible (e.g. unassigned tasks within a set of projects). Also, make sure to use pagination and be mindful of our various rate limits.

With that said, there are two approaches you could take:

  1. Get all of the tasks and then do client-side filtering based on the assignee. You can get all incomplete tasks fairly easily by specifying completed_since=now on the tasks query . While you can pass a specifc assignee (e.g. assignee=123456), the /tasks endpoint doesn’t allow you to filter on assignee=null, so you will need to do that client side.

  2. Use the search API. For example, you can search for incomplete and unassigned tasks in a workspace like this: GET /workspaces/123456789/tasks/search?completed=false&assignee=null&limit=10

Note that the search endpoint is not designed to get every task in a workspace. The results are not stable, so repeating the same query multiple times may return the data in a different order, even if the data do not change. Because of this, the traditional pagination available elsewhere in the Asana API is not available here. However, you can paginate manually by sorting the search results by their creation time and then modifying each subsequent query to exclude data you have already seen. Page sizes are limited to a maximum of 100 items, and can be specified by the limit query parameter.

Something else to note is that sections in a list project are also tasks (and will usually be unassigned). One workaround is to remove any tasks that have a name that ends with a colon.


#4

Hey Jeff,

Number 2 is exactly what I was looking for. I was trying to pull the unassigned, using the following link https://app.asana.com/api/1.0/tasks?assignee=null&workspace=[myworkspace] and that was throwing back a cannot but null error.

Now that I ran that new code you send me, it is exactly what I need!

Thanks so much for that!

Issue has been solved.