How do I get all users (and their permissions) via Jira Java API
Asked by Constantin Noll:

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](https://docs.atlassian.com/software/jira/docs/api/9.14.0/com/atlassian/jira/bc/user/search/UserSearchService.html) 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](https://docs.atlassian.com/software/jira/docs/api/9.14.0/com/atlassian/jira/bc/user/search/DefaultUserPickerSearchService.html), 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


Answers:
author: Tuncay Senturk
body: Hi [@Constantin Noll](/t5/user/viewprofilepage/user-id/5338095)

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](https://developer.atlassian.com/server/framework/atlassian-sdk/).

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

comments: author: Constantin Noll
body: Hi [@Tuncay Senturk](/t5/user/viewprofilepage/user-id/853260)   

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


Tags: jira-service-desk-data-center

jira-service-management

jira-service-management-data-center

jira-service-management-server

server