Assignee.name from a Task

I’m trying to get the Assignee name but the only results I get within the assignee object are the gid and resource type (see print screen).

Is this by design for security reasons? I’m authenticated through OAuth.

I could GET /users and associate the names through the gid but that would take a couple more lines of code. Any help would grealy be appreciated!

Cheers,
Pedro

I forgot to upload the img

Just an update. I’m having the same problem with the project name. I can’t see the project name, only the gid and resource type. I tried opt_expand.

I’m in javascript, bellow. snipped of my code:

       for (const element of idArray) {
        const data2 = await client.tasks.findById(element, {
          opt_fields: 'name, assignee, custom_fields, projects', op_expand: 'projects, assignee'
        });
        backupTaskArray.push(data2);

Hi @pedro_Botsaris and welcome to the forum!

A few points to make:

  1. opt_expand will indeed get you what you want. However, I should mention that option is no longer officially sanctioned by Asana - they’re discouraging folks from using it and they’d prefer you make the additional calls to get the additional info.

  2. opt_fields and opt_expand are mutually exclusive - you can only use one of the two, and opt_expand is a superset of opt_fields (i.e. it does everything opt_fields does plus it expands sub-objects), so if you’re going to use opt_expand (in spite of my #1 above :grimacing:), remove the opt_fields.

  3. You have a typo: you’re missing the “t” in your opt_expand.

1 Like

Thank you so much Phil. I’ll try it out!

In the opt_fields parameter, you can use the “dot” to query for subitems fields.
Example, when you query your tasks, instead of “projects” opt_fields, you can use:
opt_fields: ‘name, assignee, projects.name, projects.otherfield, …’

2 Likes

Frederic, this is perfect. Thank you so much for your help. With opt_expand I have to request way more data than what I currently need making the process clunkier

1 Like