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:
image

@Alexander_Fouse,

@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:
opt_fields=.

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.