Часть технических описаний пока доступна на английском языке.

Upload your profile picture

POST https://z.u1v.ru/api/v1/users/me/avatar

Upload a new profile picture for the current user.

The maximum allowed file size is available in the max_avatar_file_size_mib field in the POST /register response.

In organizations that restrict profile picture changes, only administrators can use this endpoint.

Примеры запросов

Параметр -u задаёт учётные данные для HTTP-аутентификации Basic. Как получить их для пользователя или бота, описано в разделе о заголовке Authorization.

curl -sSX POST https://z.u1v.ru/api/v1/users/me/avatar \
    -u EMAIL_ADDRESS:API_KEY \
    -F file=@zerver/tests/images/img.png

Параметры

The profile picture image file must be provided in the request's body as multipart form data.

Ответ

Возвращаемые поля

  • avatar_url: string

    The URL of the current user's new profile picture.

Примеры ответов

Изменения: Начиная с Zulip 7.0 (уровень возможностей 167), успешный JSON-ответ содержит массив ignored_parameters_unsupported, если запрос включает параметры, которые метод не поддерживает.

Пример успешного JSON-ответа:

{
    "avatar_url": "/user_avatars/2/c4ce28dde2d44a08b2a72cb371fe78d99cffd7c4.png",
    "msg": "",
    "result": "success"
}

An example JSON response for when the request did not include exactly one file:

{
    "code": "BAD_REQUEST",
    "msg": "You must upload exactly one avatar.",
    "result": "error"
}

An example JSON response for when the uploaded file exceeds the maximum allowed size:

{
    "code": "BAD_REQUEST",
    "msg": "Uploaded file is larger than the allowed limit of 5 MiB",
    "result": "error"
}

An example JSON response for when the uploaded file is not a supported image format:

{
    "code": "BAD_IMAGE",
    "msg": "Invalid image format",
    "result": "error"
}

An example JSON response for when a non-administrator attempts to change their profile picture in an organization that has disabled profile picture changes:

{
    "code": "BAD_REQUEST",
    "msg": "Avatar changes are disabled in this organization.",
    "result": "error"
}