Hi,
Trying to retrieve a list of users email addresses from our in-premise GitLab CE instance via the api.
I’m using “GET /user/emails” but it returns an empty string.
I do notice it mentions that there is an issue " Due to (Admin API : "GET /users/:id/emails" is inconsistent w/ documentation (#25077) · Issues · GitLab.org / GitLab · GitLab ) this endpoint currently does not return the primary email address" found here https://docs.gitlab.com/ee/api/users.html#list-emails .
I’m assuming my returned list is empty due to this bug?
Is there any other way to retrieve a list of user email addresses?
Thanks,
Craig
Hi,
I get a 404 if I try to do /user/email or /users/email, but if you install a package called jq
, you can do something like this:
curl -s --header "PRIVATE-TOKEN: your-token-here" https://gitlab.example.com/api/v4/users | jq .[].email
I am an admin, so it listed everything for me. Not sure how this would show up for a standard user, whether it would provide the email or not.
Using jq, I just filter out the returned email address from all the other JSON data.
1 Like
Hi,
Perfect! Does whats it says on the tin.
Thank you again for yet another gem of solution.
Hi,
I should have reviewed the output before posting… it seems to only of returned 20 email addresses and probably missed another 20 or so. I can’t find any limits that are set. Is this a limitation of this API request or am I missing a limit being set somewhere?
Thanks,
Not sure if this will work but try adding this to end of url
?per_page=100
So:
https://gitlab.example.com/api/v4/users?per_page=100
as the url
iwalker:
?per_page=100
Awesome, just the trick.
I did see there was a per_page parameter but couldnt see how to use it.
Much appreciated!
Can the parser help in this case, or it’s not required?