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.
| iOS | Android | macOS | Windows | ||
|---|---|---|---|---|---|
| friendInfoUpdated | onFriendInfoUpdated | friendInfoUpdated | onFriendInfoUpdated | ||
| Web | Flutter | ||||
| friendInfoUpdated | onFriendInfoUpdated |
Request method and endpoint
- 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 Common request parameters section of the Accessing Server APIs topic.
| Parameter | Type | Required | Description |
|---|---|---|---|
| FromUserId | String | Yes | The ID of the registered user whose friend's attributes are to be modified. |
| UserId | String | Yes | The list of friends whose attributes are to be modified. |
| Attributes | Array Of Object | Yes | 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. |
| Action | Number | No | The action on an attribute. 0: set the attribute. |
Attributes:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Key | String | Yes | The key of a friend attribute. Valid values: k0, k1, k2, k3, and k4. |
| Value | String | Yes | The value of a friend attribute. |
The FromUserId and UserId parameters can contain only digits, letters, and the following characters: '!', '#', '$', '%', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', ' ', ', ', '|', '~'.
Sample request
-
Request URL
https://zim-api.zego.im/?Action=UpdateFriendAttributes &<Common request parameters> -
Request body
{ "FromUserId": "zego_user", "UserId": "UserId", "Attributes": [ { "Key": "k0", "Value": "Value1" }, { "Key": "k2", "Value": "Value2" } ], "Action": 0 }
Response parameters
| Parameter | Type | Description |
|---|---|---|
| Code | Number | The return code. Note When you request to modify the attributes of multiple friends, take note of the following items:
|
| Message | String | The description of the operation result. |
| RequestId | String | The request ID. |
| FailKey | Array of Object | The list of failed results.
|
| └Key | String | The key of the attribute that fails to be modified. |
| └SubCode | Number | The code returned when the request fails. |
Sample response
{
"Code": 0,
"Message": "success",
"RequestId": "343649807833778782",
"FailKey": [
{
"key": "k0",
"SubCode": 660800032
}
]
}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 Code | Description | Solution |
|---|---|---|
| 660000001 | A common service error occurred. | Try again, or contact ZEGOCLOUD technical support. |
| 660000002 | Invalid parameter. | Check the input parameter. |
| 660300005 | The QPS limit specified in AppID is exceeded. | Try again later. |
| 660800023 | The 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. |
| 660800032 | Attributes are repeated. | Modify repeated attributes. |

