logo
In-app Chat
Powered Byspreading
On this page

Modify the attributes of a friend


Overview

You can call this operation to modify the attributes of a friend for a user.

After attributes are successfully modified, the user receives the notification in the following ZIM SDK callbacks.

iOSAndroidmacOSWindows
friendInfoUpdatedonFriendInfoUpdatedfriendInfoUpdatedonFriendInfoUpdated
WebFlutter
friendInfoUpdatedonFriendInfoUpdated

Operation prototype

  • Request method: POST
  • Request URL: https://zim-api.zego.im/?Action=UpdateFriendAttributes
  • Protocol: HTTPS
  • QPS limit: 20 calls per second

Request parameters

The following table describes only the operation-specific request parameters and some common request parameters. For the complete list of common request parameters, see the Public request parameters section of the Accessing Server APIs topic.

ParameterTypeRequiredDescription
FromUserIdStringYesThe ID of the registered user whose friend's attributes are to be modified.
UserIdStringYesThe list of friends whose attributes are to be modified.
AttributesArray Of ObjectYes

The new attributes. By default, up to five attributes of a friend can be modified at a time.

Note

The total length of the Key and Value parameters cannot exceed 1,024 bytes. If you need a higher limit, contact ZEGOCLOUD technical support. We recommend that you set a proper limit.

└KeyStringYesThe key of a friend attribute. Valid values: k0, k1, k2, k3, and k4.
└ValueStringYesThe value of a friend attribute.
ActionNumberNoThe action on an attribute. 0: set the attribute.
Note

The FromUserId and UserId parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ' ', ', ', '|', '~'.

Sample request

  • Request URL

    Untitled
    https://zim-api.zego.im/?Action=UpdateFriendAttributes
    &<Common request parameters>
    
    1
    Copied!
  • Request body

    Untitled
    {
        "FromUserId": "zego_user",
        "UserId": "UserId",
        "Attributes": [
            {
                "Key": "k0",
                "Value": "Value1"
            },
            {
                "Key": "k2",
                "Value": "Value2"
            }
        ],
        "Action": 0
    }
    
    1
    Copied!

Response parameters

ParameterTypeDescription
CodeNumber

The return code.

Note

When you request to modify the attributes of multiple friends, take note of the following items:

  • If the attributes of one or more friends are successfully modified, 0 is returned. For more information, see FailKey.
  • If the attributes of all friends fail to be modified, a corresponding code is returned. For more information, see Return codes.
MessageStringThe description of the operation result.
RequestIdStringThe request ID.
FailKeyArray of Object

The list of failed results.

  • If Code is 0:

    • If FailKey is empty, the attributes of all friends are successfully modified.
    • If FailKey is not empty, the attributes of some friends fail to be modified. In this case, see SubCode.
  • If Code is not 0:

    • If FailKey is empty, one or more parameters are invalid, the QPS limit is exceeded, or a system error occurs.
    • If FailKey is not empty, the attributes of all friends fail to be modified.
└KeyStringThe key of the attribute that fails to be modified.
└SubCodeNumberThe code returned when the request fails.

Sample response

Untitled
{
    "Code": 0,
    "Message": "success",
    "RequestId": "343649807833778782",
    "FailKey": [
        {
            "key": "k0",
            "SubCode": 660800032
        }
    ]
}
1
Copied!

Return codes

The following table describes only the return codes related to the business logic of the operation. For the complete list of return codes, see Return codes.

Return CodeDescriptionSolution
660000001A common service error occurred.Try again, or contact ZEGOCLOUD technical support.
660000002Invalid parameter.Check the input parameter.
660300005The QPS limit specified in AppID is exceeded.Try again later.
660800023The value of the Key parameter for the Attributes parameter is not k0, k1, k2, k3, or k4.Modify the value of the Key parameter. 
660800024- If it is a code, the total length of the Key and Value parameters for the Attributes parameter exceeds the limit. - If it is a subcode, the total length of friend attributes exceeds the limit after the Key and Value parameters are included.Reduce the parameter length.
660800032Attributes are repeated.Modify repeated attributes.

Previous

Change the alias of a friend

Next

Batch block users