API: Add user to project by username

Using the API (from a non-admin account), how can I add a user to a project by username?

This should be possible, as it can be easily done through the UI. However, I’m struggling to piece this together. As far as I see, I can only add a user to a project by user id. To get the ID, the /users call looks promising according to its documentation, but in practice, when the call is made from a non-admin account, it often yields no results. It looks like normal users are only shown users which are a member of a project the requesting user is a member of, too. It works fine when the request is made from an admin account.
I find this to be a bit weird, as user profiles are visible on the website – I just struggle to get there through the API.

Please note that the usernames are case sensitive.

Good point, but the casing was correct, and the output of the API call changed by promoting the user to an admin, so I don’t think this was the reason.