Typeahead API missing most tasks?

I’m trying to make use of the Asana typeahead API to provide a way for our users to link to a relevant Asana task from within our application. Unfortunately, it looks like the results I’m getting from that API are almost useless–it gives me a handful of results, but the vast majority of the tasks in our workspace are not included, even when I query for much more specific text (at which point it’s just returning an empty list).

I know that the documentation says that it’s not intended to be exhaustive, but it seems to be missing even most of the items that I see when I type stuff into the search box at the top of the Asana UI, and as-is it’s useless for successfully linking to most tasks.

Am I missing something or is this API just not sufficient for my use case?

Thanks!

@Matt_Bramlage
maybe you can help?

:thinking: Under the hood, our API is supposed to be using the exact same mechanism to get tasks, so if it’s working in our UI but not our API, something somewhere is getting wacky.

When I type the word Typeahead in our UI and issue this request

curl --header "Authorization: Bearer $ASANA_PERSONAL_ACCESS_TOKEN" "https://app.asana.com/api/1.0/workspaces/15793206719/typeahead?query=Typeahead&type=task"

I get the same tasks and in the same order from our API as our UI.

One thing that’s worth noting are that “it’s not intended to be exhaustive” is referring to 2 things:

  • Our searches are eventually consistent. In other words, brand-new tasks take a small window of time before they show up in search. This doesn’t seem like it affects this use case, however.
  • A known issue with typeaheads in our API is that they don’t support pagination - i.e. the limit and offset parameters are ignored. Instead, they just truncate results at the top 20, so they don’t offer a great way to see every task that matches the typeahead.
  • Searches are scoped to the user that’s authenticated with your app - i.e. if I search for a private task that I’m not a collaborator of, I won’t see it in the typeahead API.

If none of those apply, I’ll see if I can find out if there are other cases that might cause our API and app to return different results; you should definitely see the same results for the same user in our API and app.

2 Likes

Thanks for the response. I dug through some more and found my bug, and things are working as expected now. Sorry for the false alarm!

3 Likes

No problem :slight_smile: You had me a bit worried something seriously odd was happening on our end, so I’m glad you got it sorted out!

1 Like