Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Api to fetch users, add user, fetch billing details common to all Jira products

divya February 21, 2021

i would like to know if there is an common api for fetching users of all Jira products , adding users, fetching billing related information, https://developer.atlassian.com/cloud/ ,I have checked this documentation I cant find specific resource to fetch users , add user and billing related information.

1 answer

1 vote
Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 22, 2021

Hi @divya 

Welcome to community! You can use the users api  to fetch users and add users in your instance. However, regarding billing related information. Are there any specific information you're looking for?

divya February 24, 2021

is this "users" common to all JIRA products? and billing related information such as amount , plan name ,bill date, and other licensing related information(expiry ,renewal dates) is needed for fetching through api.

And the mentioned Api returns some unwanted information (different apps as users)along with the users list

{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=*******b9320d9ea5bdc2",
"accountId": "*******b9320d9ea5bdc2",
"displayName": "Jira Outlook",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=*********52030f1e3a5905",
"accountId": "*******52030f1e3a5905",
"accountType": "app",
"displayName": "Jira Spreadsheets",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=*******950f9f5b-3d6d-4e1d-954a-21367ae9ac75",
"accountId": "******e9ac75",
"accountType": "app",
"displayName": "Jira Service Management Widget",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=*******:f58131cb-b67d-43c7-b30d-6b58d40bd077",
"accountId": "************3c7-b30d-6b58d40bd077",
"accountType": "app",
"displayName": "Automation for Jira",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=**********b97ab11a18e00c7",
"accountId": "***************8e00c7",
"accountType": "app",
"displayName": "Halp",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=*******:0867a421-a9ee-4659-801a-bc0ee4a4487e",
"accountId": "*******:0867a421-a9ee-4659-801a-bc0ee4a4487e",
"accountType": "app",
"displayName": "Slack",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=*******:214cdd6a-ff93-4d8b-838b-62dfcf1a2a71",
"accountId": "*******:214cdd6a-ff93-4d8b-838b-62dfcf1a2a71",
"accountType": "app",
"displayName": "Trello",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=************c0efbe55103",
"accountId": "************0efbe55103",
"accountType": "app",
"displayName": "Opsgenie Integration",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=*************29c6c47967",
"accountId": "******************c68529c6c47967",
"accountType": "app",
"displayName": "Statuspage for Jira",
"active": true
},
{
"self": "https://*******.atlassian.net/rest/api/3/user?accountId=60****************0682db95d",
"accountId": "6**************db95d",
"accountType": "atlassian",
"displayName": "yello",
"active": true
},

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 24, 2021

Hi, you have to filter the result. Atlassian cloud has 4 different accountType namely:

  1. customer > for JSM customer users
  2. atlassian > for any Atlassian cloud user
  3. app > for any app on Atlassian cloud
  4. unknown > for any unknown users such as oAuth integration or there about.

Knowing the above, you should filter your output to get the desired result. For the information about billing, I'm not sure Atlassian has any public API for those but you can look into this Marketplace vendor API and see how that can help you.

Like divya likes this
divya February 26, 2021

while using the user api from my java code using url "https://*****.atlassian.net/rest/api/2/users/search?maxResults=100"

i get some users list but not complete list instead it suffixes the response with "...." like this, 

response: self":"https://****a213.atlassian.net/rest/api/2/user?accountId=-45c7-8e5c-ac6635decc67","accountId":"-45c7-8e5c-ac6635decc67","accountType":"atlassian","16x16":"https://secure...."

how to get complete list of users

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2021

Hi @divya 

You need to use pagination in your code. You can use the startAt parameter to search record by record. Run a loop and only stop the loop when you reach an empty list like [] from the payload.

divya February 26, 2021

ok

divya March 1, 2021

as per the resources.. the pagination will return some values such as total, isLast page etc ,but when I try I'm just getting the specified number of users and not the other stuff.

URL I used :  https://sitejira213.atlassian.net/rest/api/2/users?startAt=0&maxResults=6

My response : [{user},{user},{user},{user},{user},{user},{user}]  

expected response : { "startAt" : 0, "maxResults" : 10, "total": 200, "isLast": false, "values": [ { /* result 0 */ }, { /* result 1 */ }, { /* result 2 */ } ] }

Prince Nyeche
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2021

Hey @divya 

The API doesn't return the total number of user's available, you can get that from the record count.You can create a function that will produce the desired result you want. The API would just return the user's details only.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events