In-app Chat
  • iOS : Objective-C
  • Android
  • Web
  • Flutter
  • React Native
  • Unity3D
  • Windows
  • macOS
  • Introduction
    • Overview
    • Basic concepts
  • Sample app
  • Getting started
  • Client SDKs
    • SDK downloads
    • Release notes
    • Upgrade guide
  • Guides
    • Authentication
    • Manage users
    • Room
    • Group
    • Messaging
    • Call invitation (signaling)
    • Manage sessions
  • Offline push notifications
  • Error codes
  • Client APIs
  • Server APIs
  • Documentation
  • In-app Chat
  • Server APIs
  • User related
  • Modify the attributes of a friend

Modify the attributes of a friend

Last updated:2024-03-15 16:42

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.

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.

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.

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.

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.
Action
Number
No
The action on an attribute. 0: set the 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.
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.
Message
String
The description of the operation result.
RequestId
String
The request ID.
FailKey
Array 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.
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.
Page Directory