Search API Returning Zero Results

I’m trying to add search into an internal app to allow users to see a filtered list of tasks they created, and I’ve tried different invocations of the search api, and they just return empty results.
Even a simple search by creator returns no results.
Example I’ve tried:
curl -H “Authorization: Bearer ${TOKEN}” “https://app.asana.com/api/1.0/workspaces/${our_workspace}/tasks/search?created_by.any=${user_id}&sort_by=created_at&opt_fields=name,assignee.email,completed&limit=3

Respose I get with any search request:
{“data”:}

Any help would be appreciated.

Your syntax looks correct, except don’t put a $ just before your user_id. Other than that, I tried your syntax and I got results returned. So perhaps there is not data which matches your request? For example, make sure you’re using a token which has access to the data you think it does; and make sure the user_id you’re putting is really the creator of the tasks.

One thing you can try is to perform an equivalent command using the tasks endpoint in the API Explorer to see if you get the tasks returned there or not.

1 Like

The $ etc were just to remove real data and “templatize” the string for this post. The following I simplified/adjusted and copied from the example on the search api doc also returns nothing, and I am certain there are uncompleted tasks.

curl -H “Authorization: Bearer ${TOKEN}” “https://app.asana.com/api/1.0/workspaces/${OUR_WORKSPACE_ID}/tasks/search?completed=false&sort_by=created_at&opt_fields=name,assignee.email,completed&limit=3

I’ll try the API Explorer. Thanks!

1 Like

Hi! I work with Jess and I think we identified the discrepancy.

We have an internal application that uses our org’s Service Account token and it’s this token that seems to always return 0 results for the Search API. When we use a user token from API Explorer, this returns the results we expect. The Service Account token has worked fine for fetching tasks by ID and other API calls

Is this a limitation of Service Accounts? Thanks for the help

1 Like

I wish this was our issue; we started getting back incorrect results where the section filter no longer filters correctly. Fun issue since we drive automated termination of accounts from Asana tasks… undoing one is not simple.