Using Asana Search API with Python - custom fields

custom-fields

#1

Hi there!

I am trying to use Asana search API with my little program written in Python 3.
I have access to workspace ID, I have also a custom field which is an alphanumeric value, let’s call it Field 1.
Now I want to search my workspace to find a task that will have a value of this custom field set to, for example, lorem1.

Following these instructions I tried with bash curl something like this:

curl -H "Authorization: Bearer <mytoken>" "https://app.asana.com/api/1.0/workspaces/workspaceID/tasks/search?custom_fields.Field1.value=lorem1"
 and it works.

But when I want to use this in Python with a function in python asana library (here)
search_in_workspace(), it returns an error " InvalidRequestError: Invalid Request: You must specify at least one search filter."
I presume that the format of the data I am passing through is wrong (see below), but I cannot find anywhere an example of how it should look like.
My not-working code:

query= { "custom_fields" : { 'Field1' : 'lorem1' } }
find_tasks = client.tasks.search_in_workspace(workspace_id, query)

Anyone knows how the data should look like?


#2

Did you have a look at the Python library source code? @Diakoptis any idea?


#3

Hi @Kernelko,

The key-value pairs in the URL need to map exactly to key-value pairs in the query dictionary you give to the client library. In this case, the key in the URL is custom_fields.Field1.value so your input would need to be query = {"custom_fields.Field1.value": "lorem1"}