Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Search using REST API

Lee Correll
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 10, 2013

I'm attempting to generate the URL to search for users using the REST API, but not getting reasonable results.

For example, if I want to search for users whose names start with "A", I would expect to use

https://mycompany.jira.com/rest/api/2/user/search?username='\Aa*'

where \A is the regular expression anchor for start of expression, start with the letter a, and have any number of characters after the a.

What I get back is []

?? JIRA documentation says I can use a string after the username expression, and a string is defined as having a pattern, and a pattern is defined by W3 as being able to use a regular expression bounded by delimiters. Even if I do without delimiters "...?username=a*" I get a response which indicates no matches - if I just do "...?username=a", I get anything with an A in it - not that merely starts with A. (I tested this with a B, and my first response was a name starting with...A.)

Any ideas?

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Faisal
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 10, 2013

Hi Lee,

Actually to search for user starting with an 'A', you can just run the following REST request:

curl -u admin:admin http://localhost:2990/jira/rest/api/2/user/search?username=a

Based on my quick test, the above request will return users with username starting with A.

Hope that this will help.

Lee Correll
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 10, 2013

if I run that, i get JSON results back that include things like ".../rest/api/2/user?username=tadkins" as well as "...rest/api/2/user?username=mwagner""

So it's picking folks with an "a" anywhere in the username. That's why I think a regular expression is required...unless it doesn't really use regular expressions.

I'm in OnDemand, which might be different, although I can't see why.

1 vote
Lee Correll
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 22, 2013

Doesn't look like there's a solution. Moving on...

1 vote
Lee Correll
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 16, 2013

Didn't find an answer to this unfortunately, so I wound up running thru the entire alphabet, then removing duplicate entries. :(

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events