Jira Cloud API: Searching for users who have a specific User Property set via the API

Good morning,

I am working on some automations using the Jira Cloud API and have a need to find users with a specific User Entity that was set via the API.

The way it currently works is that I set a property key and value using:

/rest/api/3/user/properties/department and
{
   "ad_id": "dbelros1"
}

I am able to get this data if I query for it directly using

/rest/api/3/user/properties/department?accoundId=...

What I need to do is find a user by this using the API. I tried using /rest/api/3/user/search/query but I am unable to parse what I need for the query. I tried “department.entity.property.path” with a url-encoded version of the value above. That gives me an error 400. Quick searches around google and GitHub have yielded no examples to work with.

Can someone point me to some working examples of querying for a user by Entity Properties via the API?

Hi @DerekBelrose,

/rest/api/3/user/search allows for a property query parameter to be specified. Have you tried this?

Regards,
Dugald

Hi @dmorrow!

I did every try the property query as I stated above. It kept coming back with a poorly formed query error.

I used “ad_id.entity.property.path is” with a url encoded Jason blob that matched the value of the property.

Hi @DerekBelrose,

I did some testing in a test tenant of min. I started with a query to https://my-tenant.atlassian.net/rest/api/3/user/properties/growth-nux?accountId=my-account-id which showed I have multiple properties against my account ID, one of which has the key growth-nux.

I then inspected the details of the property with https://my-tenant.atlassian.net/rest/api/3/user/properties/growth-nux?accountId=my-account-id which revealed:

{
  "key": "growth-nux",
  "value": {
    "enrolledExperiences": {
      "PROJECT_BOARD_MODAL": "NOT_STARTED",
      "WATCH_ISSUE_SPOTLIGHT": "NOT_STARTED"
    },
    "overall": "DONE",
    "version": "v2"
  }
}

So knew the details of a specific property set against my account, I tested the searching for the property with the query https://my-tenant.atlassian.net/rest/api/3/user/search?property=growth-nux.overall=DONE and it returned an array of accounts, one of which was my account.

Note the way in which I specified the property query parameter: property=growth-nux.overall=DONE.

Regards,
Dugald

1 Like

Using the above example, property=growth-nux.enrolledExperiences.PROJECT_BOARD_MODAL=NOT_STARTED would be another example for specifying the property query parameter.

1 Like

That’s interesting. It really does not appear to be explained that way in the documentation: https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest%2F&utm_medium=302#api-rest-api-3-user-search-query-get

[propertyKey].entity.property.path is "property value" Returns users with the entity property value.

I will try this and report back. Thank you for your quick answers @dmorrow

Hi @dmorrow,

I am still working through this, here is what I have so far:
I listed the properties for my user and I have this among others:

{
    "key": "department",
    "value": {
        "ad_id": "dbelros1"
    }
}

This is what I expect to see. Now, when I go to to my tenent:

https://my-tenent.atlassian.net/rest/api/3/user/search?property=department.ad_id=dbelros1

it returns an empty array. Am I doing something wrong here?

Does this query pattern work with custom set user properties?

mmm - that looks right to me. Let me think.

According to the documentation, to search for the property you gave, the query should be:

[ad_id].value is "some_unique_string"

Is this what you have tried?

@kkercz I have tried

“[department].ad_id.value is dbelros1”
“[ad_id].value is dbelros1”

both come back with [] when using it as a ?query value and 400 if as a ?property value

Specifically when I use this:

https://my-tenant.atlassian.net/rest/api/3/user/search/query?query=[department].ad_id.value=“dbelros1”

Postman returns:

{
    "errorMessages": [
        "Unable to parse UQL"
    ],
    "errors": {}
}

And if I use the following endpoint:

https://my-tenant.atlassian.net/rest/api/3/user/search?query=[department].ad_id=“dbelros1”

I just get an empty array back (’[]’)

I’ve updated the original post with my new data which is:

{“department”: { “ad_id”: “dbelros1”}}

That’s because the operator is supposed to be “is”, not “=”.

That works!

Thank you. There seems to be a couple different ways of going about this and I was conflating them. I appreciate you helping out.

I’m still curious as to why

https://my-tenant.atlassian.net/rest/api/3/user/search?property=department.ad_id=dbelros1

doesn’t work as suggested by the documentation. But this works, so I won’t spend many cycles on it anymore :slight_smile:

2 Likes

Hi @kkercz,

It seems the documentation is inadequate and that we should fit it. What do you think?

Regards,
Dugald

I don’t know why the other API doesn’t work as advertised. Looks like either a bug or that the documentation is incorrect, yes.