Project custom field values in search API call

Hi,
I am trying to fetch the tasks using API for my team members from a project which has custom fields. I am able to fetch the normal fields using the “opt_fields” in search API.

For example, I am executing this Curl statement:

curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer xxxx' 'https://app.asana.com/api/1.0/workspaces/xxxxx/tasks/search?opt_fields=name,completed,due_on&assignee.any=username&due_on.before=2020-08-29&due_on.after=2020-08-23'

And, if I run this, I will get three field values - name completed or not and due date without any issue.

But how do I get the custom fields value in output JSON along with the standard field values?

Thanks
Suyash

Hi @Suyash_Jain, welcome to the forum !

You will get the custom fields values, by adding this to your “opt_fields” parameter:

custom_fields.enum_value.gid,custom_fields.number_value,custom_fields.text_value

But, using that, you will get values, but not the “name” of the custom field.

And, for the enum_value, again, you get an ID, not the “text” of the enum…

Names of custom fields and text of “enums” can be loaded once from the project and/or workspace definition.

When you query your projects list, asks for “custom_field_settings” opt_field to load the definition. I suggest to not query custom_field_settings from the “search” task, because you will get tons of duplicate data in return.

2 Likes