Hi Team, I want to fetch all the users that I have added in a project, is it possible to do it using an api call?
for instance I am sharing the screenshot here, I want to fetch all the users displayed next to the backlog.
Hi, it seems like you’re asking for two different things.
I want to fetch all the users that I have added in a project
Are you referring to assignable user?
If yes, then you can use this API I believe.
If you meant “I want to fetch all the users that I have assigned issues to in a project” then continue reading.
Note that a board can have multiple projects as specified by the particular board filter so you should double check whether you want all assignable users to a single project or all assignable users to all projects included in your “COM board”.
I want to fetch all the users displayed next to the backlog.
That’s just a quick filter that lists all the users that have been assigned an issue in the backlog (plus the current user).
The simplest way I can think of is to use a Jira expression to grab all the users that have been assigned an issue.
I have provided an example below but you should replace project = <YOUR_PROJECT>
with the board filter (if it’s not the default one) for more accurate results.
{
"context": {
"issues": {
"jql": {
"query": "project = <YOUR_PROJECT> AND (resolution = Unresolved AND status != Closed ) AND assignee is not empty",
"maxResults": 1000
}
}
},
"expression": "issues.reduce((assignedUsers, currentIssue) => assignedUsers.includes(currentIssue.assignee.accountId) ? assignedUsers : assignedUsers.concat(currentIssue.assignee.accountId), [])"
}
I want to fetch all the users in a project how do I do it? can you provide an example?
because I tried using the api but there is something called as porjectKeys and I do not know what that is also
when I ran this api const boardResConfiguration = await requestJira(
/rest/api/3/users
);I am getting all the users even those which I have not created like thus I want to filter it based on the accountType=atlassian property
something like this
is it possible ?
const boardResConfiguration = await requestJira(
/rest/api/3/users?accountType=atlassian
);
The project key is included as a prefix in the issue number. In your example it would be: COM
.
You can use this for all users that have been assigned an issue in your COM
project. It’s usually not possible to assign app users to issues through the web UI (should only be possible via the REST API) so I don’t think you would need to do any post-filtering to check accountType === 'atlassian'
curl --request POST \
--url 'https://your-domain.atlassian.net/rest/api/3/expression/eval' \
--user 'email@example.com:<api_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"context": {
"issues": {
"jql": {
"query": "project = COM AND assignee is not empty",
"maxResults": 1000
}
}
},
"expression": "issues.reduce((assignedUsers, currentIssue) => assignedUsers.includes(currentIssue.assignee.accountId) ? assignedUsers : assignedUsers.concat(currentIssue.assignee), [])"
}'