API - Search for users within an organization

Antonello Storelli March 25, 2024

Hi guys,

are those Request body filters available to call this API? I'm trying with postman but nothing happen using those filters, only 'limit' works.

 

https://developer.atlassian.com/cloud/admin/organization/rest/api-group-users/#api-v1-orgs-orgid-users-get

Best,

Antonello

2 answers

0 votes
David Bakkers
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 28, 2024

Hello @Antonello Storelli 

You referred to "those filters" but didn't say which ones you were trying to use, what their name is or what their purpose is.

The endpoint you provided a link to supports only two request parameters, orgId and cursor; there are no 'filter' parameters that it supports.

It would help if you provided a complete example of the request you're trying to send, including the full request path, all parameters and their values.

Antonello Storelli April 2, 2024

Hi @David Bakkers !

I was trying to use this one: https://developer.atlassian.com/cloud/admin/organization/rest/api-group-users/#api-v1-orgs-orgid-users-search-post

As you can see there are more filters that you 'can use' (as they described) in the request of the payload, but I am not able to use them, did I understand wrong?

image.png

David Bakkers
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.
April 2, 2024

That is not the same endpoint that you provided a link to in your original question, that is a different one.

Those things you are calling 'filters' are called parameters and go into the body of the request to define aspects of the request.

What EXACTLY do you mean by "I am not able to use them"? You still haven't provided the complete example of the request you're trying to send, including the full request method, path and all body parameters and their values.

Without this detailed information, there is no way to just randomly guess what you might be doing and what the problem might be.

Also, are you completely, absolutely positive your organisation has the new user management experience in place, which is declared in that endpoint's documentation:

Returns a list of users with applied privacy controls in an organization using the new user management experience

Antonello Storelli April 3, 2024

Hi David,

I know where they are, into the body request, and the parameters are used to filter results, so, to me, they are filters. If I don't put any of them I get all the records, instead, if I put a parameter called 'limit:20' I filter the result to 20 records. So they are filter. It doesn't matter anyway.

The API works with the standard limit parameter:

image.png

 

If I try for example 'accountStatuses' to filter only inactive users it didn't work to me. i did it in this way:

image.png

Antonello

David Bakkers
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.
April 7, 2024

Hello @Antonello Storelli 

You're not forming the request body's JSON properly. The documentation says those parameters require an array<string>, not a string. In JSON, arrays are wrapped in double brackets ie: [ "string1", "string2", "etc"]

The format of your request body should be something like this:

 

{
    "limit": 20,
    "isSuspended": "false",
    "accountTypes": ["atlassian","app"],
    "accountStatuses": ["ACTIVE"],
"expand": ["EMAIL","NAME"]

}
When supplied with an array of strings, those parameters work exactly as expected.
I have found there is a mistake in the accountStatuses parameter documentation. It says the two valid values are 'active' and 'inactive', but this isn't correct. Those values must be in UPPERCASE as 'ACTIVE' or 'INACTIVE'.
You're welcome to log this mistake in the documentation as a bug with Atlassian.
Rick Westbrock April 8, 2024

@David Bakkers the problem I am facing is that when searching by emailUsernames it requires one of two child properties, both of which require an array of strings: eq and contains.

I am using the JSON below which is valid and returns an HTTP 200:

{
  "limit": 20,
  "expand": ["NAME", "EMAIL", "PRODUCT_LAST_ACCESS"],
  "emailUsernames": {
    "eq": ["username@example.com"]
  }
}
The response body has an empty list for both "data" and "links" elements however;
{
    "data": [],
    "links": {}
}

 

I think that I must not understand what emailUsernames is searching on because when I use the same JSON structure for emailDomains as shown below it does return the expected accounts:

{
  "limit": 20,
  "expand": ["NAME", "EMAIL", "PRODUCT_LAST_ACCESS"],
  "emailDomains": {
    "eq": ["example.com"]
  }
}

 

My objective is to fetch the account ID of the account having a specific e-mail address so my assumption was that emailUsernames was the way to do that.

Rick Westbrock April 8, 2024

I figured out how emailUsernames works, it only wants the string before the domain so this is the proper JSON format when I am searching for an account which has e-mail address username@example.com:

{
  "emailUsernames": {
    "eq": ["username"]
}
Like David Bakkers likes this
David Bakkers
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.
April 8, 2024

Yep, the documentation for these endpoints is sparse, to say the least. Thankfully, I don't have to interact with them very often :)

0 votes
Antonello Storelli March 27, 2024

Hello folks! No one is using it? No one can help me to understand how it works?

Best,

Antonello

Rick Westbrock April 5, 2024

accountStatuses shows that it wants an array of strings so my assumption is that the JSON body would use the following:

"accountStatuses": ["inactive"]

 

That doesn't work however as it returns an HTTP 400 error. That really surprised me because accountIds also shows it wants an array of strings and the JSON below returns the correct account:

 

"accountIds": ["557058:214cdd6a-ff93-4d8b-838b-62dfcf1a2a71"]
I found the documentation to be a bit lacking myself, for example I want to search using emailUsernames which shows that it has two child properties for eq and contains where eq wants an array of strings but it doesn't explain how to construct the JSON for a child property.

Suggest an answer

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

Atlassian Community Events