Typeahead return no results for empty string

Hi I’m making a call to typeahead api for users and I’m bumping into an issue where I receive an empty result whenever I send an empty string, but get a results list when I add a string to the query. I’m not sure if this is a bug, or if there is something that I am missing on my end. Please let me know what my next steps should be or how I can proceed from here.

Here is the query in question which returns an empty list. https://app.asana.com/api/1.0/workspaces/<<workspace-id>>/typeahead?opt_fields=&resource_type=user&type=user&query=%20&count=100

1 Like

Ah sorry, posted the wrong url. the url is as follows
https://app.asana.com/api/1.0/workspaces/430978515275406/typeahead?opt_fields=&resource_type=user&type=user&count=100

My initial thought is that a typeahead is by design something to help you “finish” your request, so you do need to write at least something…

hmm, the documentation seems to suggest an empty string should yield results:

Leaving the query string empty or omitted will give you results, still
following the resource ordering above. This could be used to list users or
projects that are relevant for the requesting user’s api token.

Perhaps the phrase “relevant for the requesting user’s api token” is related? unsure.

It does sound like it should work.

I looked at my Flowsana app-component code in an effort to hopefully help you, and I found that I use typeahead for every other object type that I need, except that for users, my typehead code is commented out and replaced with the use of a dropdown instead.

I wish I could remember the details of why I did that, but it seems suspicious, as in, maybe I tried typeahead for users and it didn’t work right so I had to use the dropdown control. I’m not sure that’s why I have it commented out and replaced, but it might be!

1 Like

Thanks Andrew for sharing, I was unaware of this part of the API!

Hi,

In our app, we use typeahead, to get the most revelant users, tags, and projects, to the user.

We query using “empty string” and “wildcard”, limit 100.

The reason we get result is not always clear, sometimes we get results on empty, sometimes on wildcard, sometimes on both or none.

But I just tried, and I get results for my projects using empty string, and for users using wildcard “*”.

So, it’s not clear how it works / why it returns “these” results, but it works.

Very useful for account that has thousands of users or projects.
And, almost the only safe method to retrieve a tags list.

1 Like