I have site admin access, but for two groups they keep returning
"Specified user does not exist or you do not have required permissions" using Rest API
Currently the API works with adding users to other groups, but for some reason these two are not playing ball.
In Jira Automation
Web Request
Get
https://myinstance.atlassian.net/rest/api/3/user/search?query='{{Issue.Email}}'
user xxxxx:xxxx
Content-Type application/json
Authorization Basic xxxx
Accept application/json
This works
Status 200s returned and Account ID is then grabbed as a variable and recoded in audit to confirm it has been grabbed
Post
https://myinstance.atlassian.net/rest/api/3/group/user?groupId=zzzzzzz
user xxxxx:xxxx
Content-Type application/json
Authorization Basic xxxx
Accept application/json
{
"accountId": "{{AccID}}"
}
For every other group bar two this works
But for 2 groups it returns either
400
{errorMessages=[Cannot add user. User is already a member of '{1}'], errors={}}
This is OK as means someone has manually put them in the relevant group
Or
404
{errorMessages=[Specified user does not exist or you do not have required permissions], errors={}}
But
- user exists as they were found via their email and the account ID returned, so that rules out Specified user does not exist part of the error
- I have the permissions as, 1) the user n Auth work on the Get and on other group adds, 2) I am site admin
So not sure why this is glitching on two of the groups.
Hi @Mark J Cunningham ,
You an try debugging the AccID by using the "Log Action" to print out the {{AccID}} in the Log Action, and verify if the value fetched it correct.
If the value is correct and still not working, would recommend 2 approaches:
1. Try adding to that group manually, being a site admin it should work for your user
2. Use Postman to try out the same and then debug if there is some change in the syntax that needs to be capture
Hope this helps.
Found it was an even odder quirk
For some user doing the get user from email string returned 2 or 3 account IDs for that email address, rather than one
Yep very odd
So the three were then trying to be fetched for the post to group
Fix was to split the automation down further (really wish you could branch a branch and the jira automation ran in series rather than parallel)
So ended with
WebRequest - get user via email
Check if 200 returns
create variable for AccountID
Branch - Split variable at ","
Then for each
Post to add to group
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad to know you found the solution.
If this thread helped would request you to mark this as the Accepted answer so that it can be referenced by others too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Better solution
double email search
Oddly:
in the Get
https://<your instance>.atlassian.net/rest/api/3/user/search?emailAddress={{Issue.Email}}&query={{Issue.Email}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.