Hi @John_Craven,
It took me a bit to actually reproduce what you were seeing - our API explorer doesn’t make it easy to get into that query you were using! (I expect you added an additional field for section manually in the API explorer?)
Filtering on section is actually not documented; if you check out the third example under the documentation on querying for tasks, you can see that specifying section isn’t supported. I think it’s fairly accidental that it works for you, so it’s unfortunately an unreliable thing to do.
The difference you’re seeing between when it works and when it doesn’t is actually due to something else entirely than simply where the query is being constructed - we’re rolling out a new version of the API that is a complete rewrite, but much faster. I verified that if you happen to hit the older version of the API, it works, but if you hit the newer version, it tells you that you can’t filter on section, only projects, tags, or assignee and workspace. This is actually the expected behavior. (The reason you were seeing it as different between querying in the explorer and in a console is because we authorize users differently in the browser and in a console, and auth credentials is what we’re using to partition requests to do our incremental roll-out.) In general, a query in the API explorer and in the console should do the same thing.
To filter to section, unfortunately, the right thing to do right now is to get all of the tasks in the project, then filter client-side on the section. To do that, you have to construct the query to ask for the sections information in the tasks ‘memberships’ field to be shipped back (when you query for tasks on a project, you normally get the compact representation of only name and ID). For instance, you can construct the url with opt_fields
like this:
https://app.asana.com/api/1.0/tasks?opt_pretty&project=[project_id]&opt_fields=this.name,this.memberships.section,this.memberships.section.name
(note also that I specified task name should come back as well: when we ask for specific fields, we no longer return the compact representation, but only those fields that you specifically ask for. Similarly, for illustration purposes, I asked for the section name; without that, you only see the ID, which is really what you should be filtering on client side)
We have an outstanding opportunity for implementing filtering on sections, so perhaps in the near future, we’ll officially support the kind of query you’re looking for.
I hope this makes sense! Good luck!