Is it possible to get expanded user information from Jira Cloud?

Originally asked by Gabor Tavali on 07 August 2020 (original question)


Currently in Exalate I get the following properties as a user from Jira Cloud:

{
      "key": "",
      "active": ,
      "email": "",
      "displayName": ""
    }


Is it possible to get more details about the Jira user? I mean I have more properties in Jira side (e.g phone number, some other ids, etc…), customs as well. It would be nice if somehow I could be able to get those information as well.

Thank you!


Answer by Francis Martens (Exalate) on 10 August 2020

Hello Gabor Tavali

Where is this information stored?


Comments:

Gabor Tavali commented on 10 August 2020

Hey Francis Martens (iDalko)

We have some extra user information in Jira (company ids). It can be anywhere in Jira side, the question is, where should we store them if we want to get it in Exalate?

Francis Martens (Exalate) commented on 10 August 2020

You lost me (old community)

Are you already storing this information in cloud,

Where do you need these in server …

Please provide much more context - thanks

Gabor Tavali commented on 10 August 2020

Sorry if I was misunderstood. (old community)

I’d like to store some extra information for all users (employee id) in Jira Cloud, but it doesn’t matter where. We can put the custom information anywhere in Jira you prefer. The goal is to get that custom user field in Exalate when we define the mapping rules.

Is it possible?

Francis Martens (Exalate) commented on 10 August 2020

Ah - you would like to add to a user specific values.

Do you know if there is a rest api for this entity type?

You can then use the JiraClient to set/access that information

Check for an example
https://docs.idalko.com/exalate/x/BoEAAg

Gabor Tavali commented on 10 August 2020

Thank you, it’s useful! I give it a try!

Gabor Tavali commented on 11 August 2020

Francis Martens (Exalate) I’ve tried the JiraClient based on your example:

def wc = new JiraClient(httpClient)
        def groupsResultStr = wc.http(
                "GET",
                "/rest/api/3/user/properties",
                ["accountId":"5ce5eec03b428d0dcd7cac19"],
                null,
                [:]
        )

I got the following error:

Script error for issue ST-26. Details: Failed to perform the request GET /rest/api/3/user/properties (status 404), and body was: ```null``` Please contact Exalate Support: {"errorMessages":["Specified user does not exist or you do not have required permissions"],"errors":{}}. Error line: JiraClient.groovy:88

The error is on the Jira side. Could you help in this issue?

Juan Grases commented on 11 August 2020

Hi! There is an easier way to interact with the Jira Cloud REST API:

def userProperties = httpClient.get("/rest/api/3/user/properties?accountId=5ce5eec03b428d0dcd7cac19")

No need to do any json parsing on the result (userProperties), is already parsed into a groovy Map.

Could you try this way? Make sure the request you try is valid (you can test directly on your browser)

Gabor Tavali commented on 11 August 2020

Hi Juan Grases ,

Thanks for the answer! I’ve tried but I got null object.

def userProperties = httpClient.get("/rest/api/3/user/properties?accountId=5ce5eec03b428d0dcd7cac19")
def keys = userProperties.keys

The error is the following:

Script error for issue ST-26. Details: Cannot get property 'keys' on null object. Error line: Script403.groovy:23

In a browser I can get answer for that accountId. What could be the problem?

Juan Grases commented on 11 August 2020

Could you share what is the answer you get from the browser when doing /rest/api/3/user/properties?accountId=5ce5eec03b428d0dcd7cac19 on your Jira Cloud?

Gabor Tavali commented on 11 August 2020

Sure!

{
"keys": [
{
"self": "https://***.atlassian.net/rest/api/3/user/properties/growth-nux?accountId=5ce5eec03b428d0dcd7cac19",
"key": "growth-nux"
},
{
"self": "https://***.atlassian.net/rest/api/3/user/properties/jsw-onboarding-checklist.create-project-task?accountId=5ce5eec03b428d0dcd7cac19",
"key": "jsw-onboarding-checklist.create-project-task"
},
{
"self": "https://***.atlassian.net/rest/api/3/user/properties/jsw-onboarding-checklist.onboarding-status?accountId=5ce5eec03b428d0dcd7cac19",
"key": "jsw-onboarding-checklist.onboarding-status"
},
{
"self": "https://***.atlassian.net/rest/api/3/user/properties/jsw-onboarding-checklist.open?accountId=5ce5eec03b428d0dcd7cac19",
"key": "jsw-onboarding-checklist.open"
},
{
"self": "https://***.atlassian.net/rest/api/3/user/properties/jsw-onboarding-checklist.open-task?accountId=5ce5eec03b428d0dcd7cac19",
"key": "jsw-onboarding-checklist.open-task"
}
]
}
Gabor Tavali commented on 13 August 2020

Hey Juan Grases

Do you have any idea why I get null object instead of the above?

Is it possible that the Jira user who initiates the REST call on behalf of Exalate, it doesn’t have appropriate permissions?

Francis Martens (Exalate) commented on 13 August 2020

hmm - that might be the case although Exalate has been whitelisted to access user information.

Gabor Tavali commented on 13 August 2020

We’re gonna check it! Thanks! The user who initiates the call, is the same as the reporter user “Exalate” after a successful sync?

Francis Martens (Exalate) commented on 13 August 2020

yes should be

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.