How do I set a profile picture for a user in GitLab via the API?

Question:

How do I set a profile picture for a user in GitLab via the API?

Answer:

Starting with version 9.4, a parameter for user avatar has been added to the API.

From the documentation :

avatar (optional) – Image file for user's avatar

Using CURL, the image can be loaded via the form option:

curl --request PUT --header "PRIVATE-TOKEN: %TOKEN%" --form "avatar=@%PATH_TO_FILE%" https://%GITLAB_URL%/avi/v4/users/%USER_ID%
Scroll to Top