Search API Returning Zero Results

search
#1

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.

0 Likes

#2

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

#3

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

#4

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