0

I need to get a list of users who logged in within the last 2 years. YouTrack Web interface shows me 141 users on /admin/hub/users?query=lastAccess(after:%202018-01-01)

But when I try to get the same list via API, I get an empty array. What am I doing wrong? Here's my API request:

curl -X GET "https://[my_youtrack_URL]/api/admin/users?query=lastAccess(after:%202018-01-01)&$skip=0&$top=200"

2 Answers2

1

What am I doing wrong?

You're missing an authentication token. Try adding the following to your curl command -H "Authorization: Bearer mytoken123". The token itself can be created in your YouTrack user profile.

Jk1
  • 11,233
  • 9
  • 54
  • 64
  • Thank you for your answer, but that's not the case - I just didn't list the whole request. I have an auth token and all other headers, and some other requests I make work well. It's something in the query syntax of this particular one. – Dmitry Linov Feb 04 '20 at 10:05
  • I see. Then it must be the wrong API endpoint you refer to. Give `https://[my_youtrack_URL]/hub/api/rest/users` a try. – Jk1 Feb 04 '20 at 12:27
  • you're right, but that appeared to be only one half of the answer. See below. – Dmitry Linov Feb 04 '20 at 22:18
0

I got the answer from the YouTrack developers, it's two-fold:

1) First, the endpoint for request concerning users is different - this is a "hub" feature, so the endpoint should be /hub/api/rest/users (as also mentioned by @Jk1 above).

2) Second, the correct syntax for the query is lastAccess(after:+2018-01-01) (+ instead of %20).