API Search for Tasks by Assignee or Follower

I have the following API call (via the Ruby client)

[Asana::HttpClient] GET https://app.asana.com/api/1.0/workspaces/{workspace_gid}/tasks/search ({:text=>"*", :assignee_any=>“8033…”, :followers_any=>“8033…”, :modified_at_after=>“2020-05-02T23:48:33-05:00”, :opt_fields=>“gid,name,modified_at,assignee,followers”})

And the hits are all the most recently modified tasks that have no matches at all on assignee or follower, as if it’s just ignoring that criteria. I’m just looking for the most recent tasks where a specific user is the assignee or a follower. I tried it also with just assignee_any or followers_any - same results either way. This seems broken?

I am shoe-horning in an asterisk wildcard in for the text, which I couldn’t find any documentation support for, though I’d think if that’s not a wildcard, it just wouldn’t return anything (or would return tasks with a literal asterisk in it)

I can search only by assignee with this API, this seems to work, but I can’t find modified tasks I’m following:

[Asana::HttpClient] GET https://app.asana.com/api/1.0/tasks ({:assignee=>“8033…”, :workspace=>“499…”, :modified_since=>“2020-05-03T00:00:34-05:00”, :limit=>20, :opt_fields=>“gid,name,modified_at,assignee,followers”})

I think you should try to remove that parameter, text “*”. I use that endpoint to search for other criterias and I never add any “text” parameter, just ids or dates that I need to filter.

When I remove the text param, the call fails, telling me:

[Asana::HttpClient] GET https://app.asana.com/api/1.0/workspaces/499.../tasks/search ({:assignee_any=>"803...", :followers_any=>"803...", :modified_at_after=>"2020-05-03T11:13:43-05:00", :opt_fields=>"gid,name,modified_at,assignee,followers"})

Asana::Errors::InvalidRequest: You must specify at least one search filter.

I was presuming text was a required search filter. So … maybe I overlooked it in the documentation.

Oh I see. The error is right, you did not provide any search filter.
Because, the parameters are:
followers.any instead of followers_any. Same for modified_at.after, …

Ah! A flaw in the code generator of the params for the Ruby gem. The params get translated as Hash keys for the Ruby code, but a period isn’t a legal character in a key symbol for the Hash key, so something, I’m guessing, is translating the periods to underscores. At one point I briefly noted the params having periods in the docs, but since the gem had one instance of this API call with explicit key name args with underscores, I presumed they’d be doing the proper magic underneath.

There is a second way inside the Ruby library to call this same API endpoint, without the key name method arguments, which can allow the special “string symbol” syntax in Ruby to include the period. Changing to that has this working!

I’ve filed this issue: https://github.com/Asana/ruby-asana/issues/93

Thx @Frederic_Malenfant!

1 Like