Querying project information (including custom fields) in one query
Hi there,
I'm working on a bug reporter built into our software using the REST API for YouTrack. The flow for retrieving the custom field information for the project seems really cumbersome (as documented here: Create an Issue and Set Custom Fields - Help | Developer Portal for YouTrack and Hub (jetbrains.com)
I think there's an easier way, but it seems like the user must have admin rights to do it - using a URL like:
/api/admin/projects?fields=id,name,shortName,customFields(id,type,field(name),bundle(id,values(id,name)))&query=AB
That collects all of the relevant data in a nice format. Unfortunately if the user isn't admin, the custom fields come back empty (though the rest of the information is there).
Given that custom fields aren't data that's hidden from non-admin users, should this work? The alternative requires multiple queries and a lot more data-wrangling to get the responses into a usable structure.
So I guess this is both a request for help and (if there's no better way) a feature request to provide an easier API for querying a project's custom fields.
Thanks,
Rob.
Please sign in to leave a comment.
Hi!
I'm Sergey from the YouTrack team.
When querying an issue, you can get a list of fields that the user can see in the specific issue only. There can be multiple other fields added to the project that the user doesn't see (e.g., due to visible settings, conditions, etc). So, this is not exactly a viable option for retrieving all the project fields if that's the goal.
This is the correct way to retrieve all the project fields. And yes, this requires a permission (Update Project) to access the project settings; otherwise, any user would be able to retrieve fields they cannot access, leading to a security issue.
I've figured you can skip the first couple of steps and go straight to querying the top issue if you already know the project name. That'll do for now (although it seems odd that the way to get a list of the custom fields for a project is to get the information about one arbitrary issue and find them in there).