Question

Issues with Atlassian Groups Adding/Removing Users

  • 8 December 2020
  • 13 replies
  • 452 views

Userlevel 1
Badge +1

Precursor: First off I want to say I’ve been working with BetterCloud support who have been awesome as always but we’re unable to find a resolution to this issue. I have successfully integrated Atlassian using a service account with the correct Admin rights.

Issue: I have been able to Create users, but not add some users to Atlassian groups. My goal is to create a workflow where if they get added to a specific Okta group, they’re put into the correct Atlassian group. When I try to add a user to an Atlassian group, it responds back with:


More than one user found for email 'user@mycompany.com' or email was not recognized. Please verify that email is correct

 

I did some digging and confirmed via Postman that hitting the https://{base_domain_URL}.atlassian.net/rest/api/3/user/search?query={email}​ API with my service account I was able to get a response.

The problem is, I get 2 responses back:

  1. accountType: customer
    email: user@mycompanny.com
  2. accountType: atlassian
    email: user@mycompany.com

We use Jira Service Desk and setup our users as customers in order to submit tickets. Atlassian added the accoutType preference to this query recently which is why it includes one email as both a customer & atlassian (actual user account).

When using the Adding/Removing user to group function for Atlassian, BetterCloud has not yet added the logic to parse this out when you get multiple responses.

I’m curious if other have run into this issue and/or have a workaround?


13 replies

Userlevel 5
Badge +2

@jb.lovell@justin.little@catherine.achukwu have you seen anything like this when working with Atlassian?



Open Thread in Slack
Userlevel 5
Badge +2

and @bmorse when it returns that response, is it in the form of an array?



Open Thread in Slack
Userlevel 1
Badge +1

Cleaned up the response for anonymity purposes but here's what it looks like:

[
    {
        "self": "https://mycompany.atlassian.net/rest/api/3/user?accountId=qm:4f7f875e-26e7-42f1-b3a4-6c2e7f082b79:ea203742-84ab-434f-b628-3u382392",
        "accountId": "qm:4f7f875e-26e7-42f1-b3a4-6c2e7f082b79:ea203742-84ab-434f-b628-3u382392",
        "accountType": "customer",
        "emailAddress": "user@mycompany.com",
        "avatarUrls": {
            "48x48": "",
            "24x24": "",
            "16x16": "",
            "32x32": ""
        },
        "displayName": "user@mycompany.com",
        "active": true,
        "timeZone": "America/Los_Angeles",
        "locale": "en_US"
    },
    {
        "self": "",
        "accountId": "5e2b84beadb9030e228829746",
        "accountType": "atlassian",
        "emailAddress": "user@mycompany.com",
        "avatarUrls": {
            "48x48": "",
            "24x24": "",
            "16x16": "",
            "32x32": ""
        },
        "displayName": "My User",
        "active": true,
        "timeZone": "America/Los_Angeles",
        "locale": "en_US"
    }
]


Open Thread in Slack
Userlevel 5
Badge +2

yep, looks like an array. best bet would be to take the response and use the one where response[x].accountType === "customer"



Open Thread in Slack
Userlevel 1
Badge +1

I tried to do that by manipulating the URL but it doesn't look possible. Most likely need to do it as BC Custom Integration with a transformation script using your method.



Open Thread in Slack
Userlevel 5
Badge +2

yep, exactly



Open Thread in Slack
Userlevel 5
Badge +2

to your point, it would be nice if they allowed you to filter that up front in the url



Open Thread in Slack
Userlevel 5
Badge +2

Atlassian documentation does say:



Open Thread in Slack
Userlevel 5
Badge +2

A query string that is matched against user attributes, such as displayName and emailAddress, to find relevant users. The string can match the prefix of the attribute's value. For example, query=john matches a user with a displayName of John Smith and a user with an emailAddress of johnson@example.com. Required, unless accountId is specified.



Open Thread in Slack
Userlevel 5
Badge +2

have you tried:

https://{base\_domain\_URL}.atlassian.net/rest/api/3/user/search?query={email} AND accountType is "customer"

it seems like a crazy query for a URL but their documentation makes it seem it make work



Open Thread in Slack
Userlevel 2
Badge +2

You can do the filtering after you get the API response



Open Thread in Slack
Userlevel 2
Badge +2

Mind posting your script and I can probably add it in real quick



Open Thread in Slack
Userlevel 1
Badge +1

have you tried:

https://{base\_domain\_URL}.atlassian.net/rest/api/3/user/search?query={email} AND accountType is "customer"

it seems like a crazy query for a URL but their documentation makes it seem it make work

 


Open Thread in Slack

 

I’ve tried going the route of https://mycompany.atlassian.net/rest/api/3/user/search?query=user@mycompany.com&accountType=atlassian but it doesn’t seem to like it. I’ve tried URL encoding it many different ways with no success.

Reply