How do I get all users (and their permissions) via Jira Java API

Constantin Noll February 29, 2024

Hello,

I have to write a Spring Boot Microservice which accesses an onPrem Jira ServiceDesk instance and lists all users and their permissions to put them in a centralized UAM tool.

I did this before with Typescript via Jira Rest API, but we decided to consolidate our microservices and use a common stack for all.

I'm new to all of the tools: Java, Spring and Jira.

However, I found this maven dependency:

<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-api -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>9.11.1</version>
<scope>provided</scope>
</dependency>

And I found a UserSearchService.class which provides findUsers methods and I assume, that's my entrypoint.

But I could not figure out, how to create one.
I saw the DefaultUserPickerSearchService, but it has a inconvenient constructor and I think it is not the way to go to construct it on my own.

I found an example like:

UserSearchService userSerachService = ComponentAccessor.getComponent(UserSearchService.class);

But, I get an error log like:

This is not expected to occur on a production system. 
Developers that encounter this message within a unit test ...

Also, I cannot see any place where I can provide a host or credentials.

I did the same task before with AWS and they had a documentation like:
https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/basics.html
https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/examples-iam-users.html

Is there a simlilar documentation with examples for the Jira Java API?

Or could someone provide an example which starts with authentiction and ends with a UserSearchService?

Thank you in advance.
Constantin

 

1 answer

1 accepted

0 votes
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 3, 2024

Hi @Constantin Noll 

Welcome to the Community!

Are you developing a plugin intended to operate within Jira, or are you creating an external application that queries Jira for user information?

If your goal is to create a plugin for Jira, the mentioned dependency is appropriate for your Java project. However, you'll first need to set up the Atlassian SDK. Detailed guidance on utilizing this dependency, including how to inject runtime services into your Java constructor or leverage Spring Scanner, can be found in the relevant tutorials.

On the other hand, if your project involves building an external system aiming to interact with Jira, I would not recommend using the specified dependency approach. Instead, you should directly interact with Jira's REST API and request users.

Best

 

Constantin Noll March 4, 2024

Hi @Tuncay Senturk 

Actually, I'm developing an external Application not a Jira Plugin.

So, I'll stay with the ReST API I used before.

Thank you for this advice. :)

Kind regards
Constantin

Like Tuncay Senturk likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events