API: how to delete an avatar?
Projects, groups, users and topics have an avatar (image). Via API, a file can be uploaded as avatar:
To upload an avatar file from your file system, use the
--form
argument. This argument causes cURL to post data using the headerContent-Type: multipart/form-data
. Thefile=
parameter must point to a file on your file system and be preceded by@
.
curl --request PUT \
--header "PRIVATE-TOKEN: <your_access_token>" \
"https://gitlab.example.com/api/v4/topics/1" \
--form "avatar=@/tmp/example.png"
This works well so far. But what if you don't want the avatar anymore?
How can I delete the avatar of a project/group/user/topic via API?
Different attempts are failing:
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --form "avatar="
{"error":"avatar is invalid"}
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --form "avatar=nil"
{"error":"avatar is invalid"}
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --form "avatar=''"
{"error":"avatar is invalid"}
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --form "avatar=@"
{"id":9,"name":"topic1","description":"","total_projects_count":0,"avatar_url":"http://localhost:3000/uploads/-/system/projects/topic/avatar/9/avatar.jpg"}
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --form "avatar=@''"
curl: (26) could not open file "''"
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --data "avatar="
{"error":"avatar is invalid"}
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --data "avatar=nil"
{"error":"avatar is invalid"}
>curl --request PUT --header "PRIVATE-TOKEN: ..." http://localhost:3000/api/v4/topics/9 --data "avatar=''"
{"error":"avatar is invalid"}