opt_fields and fields behaving identically?

I’m using the Node.js setup. When I request stories and supply {opt_fields: [“assignee”]}, it’s as though I didn’t supply anything and I get the normal response (though I’m missing the ‘assignee’ optional field). However, if I remove the array brackets, I only get the assignee field, as though I passed fields: “assignee”.

Where am I going wrong?

myclient.stories.getStory(storyID, {opt_fields: [“assignee”]}) – yields a standard response without the assignee field

myclient.stories.getStory(storyID, {opt_fields: “assignee”}) – yields only the assignee field

myclient.stories.getStory(storyID, {fields: “assignee”}) – yields only the assignee field

I believe opt_fields takes a comma separated list as an argument, not an array.

From the documentation:


@Bastien_Siebman is right and the docs are wrong. (Note to @AndrewWong …)

In other words:

Right - that’s the incorrect syntax so opt_fields is isgnored

Right - now opt_fields is in effect, and that’s its behavior - when you specify it, you get only the specified fields in your response.

Huzzah. I can accept documentation needing updates. Thank you

Follow-up: Is there any way to select all available fields? Or any reference for all fields that can be selected?

I believe you can use a dot:

Keep in mind that the more fields you ask for, the more expensive your request becomes, and the quicker you’ll reach rate limits.

1 Like

Yes, excellent point.

1 Like

This returns no fields for me (other than the always returned gid and resource_type).

Yeah, I just tried it and I see it doesn’t work as I thought it might. Sorry about that!

They might have changed it as part of the fact that opt_expand is also deprecated.

Hi there, where would I go to ask that the documentation is updated? I also thought it worked the same way as @Alexander_Fouse. Can I just raise an issue in the repo?

There are a couple of errors I have found throughout the documentation and it makes it more difficult to use than it should be.

I suggest you write to api-support@asana.com

1 Like