Message queues
Update time: 2022/12/13 09:48:06
Manage elements in a message queue.
By defining the values of key-value pairs for the elements in the chat room queue, the elements can be managed using various methods.
Add or update an element
Add or update an element in a chat room queue.
If the element added by User A is updated by User B, the owner of the element is User B.
URL
httpPOST https://api.netease.im/nimserver/chatroom/queueOffer.action HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8
Request parameters
- For information about the header in a POST request, see Overview.
- The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | long | Yes | Chat room ID |
key | String | Yes | elementKey, the unique key of a new element, up to 128 characters. |
value | String | Yes | elementValue, the value of a new element, up to 4,096 characters. |
operator | String | No |
The account ID of an operator submitting a new element. The creator of a chat room is used by default. If the account corresponding to the operator does not exist, a 404 error will be returned. If the specified operator is not online, the operator in the notification event after the element is successfully added is the creator of the chat room by default. If the specified operator is online, the operator of the notification event is the operator. |
transient | Boolean | No |
Whether the added element must be deleted when all the chat rooms of the operator are disconnected or the operator leaves the chat room. true: delete the element, false: does not delete the element. The default value is false. If this parameter is set to true and the operator is not in the chat room, a 403 error will be returned. |
Example
Example request (cURL)
curlcurl -X POST -H "CheckSum: 32dc17***c9367e7" -H "AppKey: fe416640***ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Cache-Control: no-cache" -H "Postman-Token: b9550dce-74c1-9606-0084-71dd8ec201b6" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&key=1111&value=66666' "https://api.netease.im/nimserver/chatroom/queueOffer.action"
Response
json"Content-Type": "application/json; charset=utf-8"
{
"desc": {
},
"code": 200
}
Add multiple elements
Add multiple elements in a chat room queue
- If the chat room queue is not initialized, the queue will be automatically initialized and the notification for queue initialization will be received.
- If the account to which the queue element belongs is offline and not the creator of the chat room, adding elements will fail.
URL
httpPOST https://api.netease.im/nimserver/chatroom/queueBatchOffer.action HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8
Request parameters
- For information about the header in a POST request, see Overview.
- The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | Long | Yes | Chat room ID |
operator | String | No | The account that initiates the queue operation is the chat room creator by default. |
transient | Boolean | No |
Whether the added element must be deleted when all the chat rooms of the operator are disconnected or the operator leaves the chat room. true: delete the element, false: does not delete the element. The default value is false. If this parameter is set to true and the operator is not in the chat room, a 403 error will be returned. If the transient configuration is not specified for adding multiple elements, this configuration will be used. |
elements | JSONArray | No |
Elements in a queue, up to 20 elements in the following format:
[ { "key": "key01", //Element key "value": "{\"priority\":10}", //Element value "accid":"user01", //Account to which an element belongs // if accid is unspecified, the default value is operator "transient":true //Whether elements are deleted when leaving a chat room. //If transient is unspecified, the default value is used. } ] |
needNotify | Boolean | No | whether notifications are sent for update events, The default value is true. |
notifyExt | String | No | Extension field for notification events, up to 2,048 characters |
Example
Example request (cURL)
curlcurl -X POST -H 'appkey: fe416640***47ad2547' -H 'cache-control: no-cache' -H 'checksum: 18f54***f75265495034' -H 'content-type: application/x-www-form-urlencoded' -H 'curtime: 1508481877' -H 'nonce: 12345' --data-urlencode 'roomid=64' --data-urlencode 'operator=user01' --data-urlencode 'transient=false' --data-urlencode 'needNotify=false' --data-urlencode 'elements=[{"key":"key01","value":"{\"priority\":10}","accid":"user01","transient":true}]' "https://api.netease.im/nimserver/chatroom/queueBatchOffer.action"
Response
json
"Content-Type": "application/json; charset=utf-8"
{
"code": 200,
"desc": {
"failedKeys": [ //Keys that failed to be added.
"key01"
]
}
}
Update multiple elements in a queue
Update multiple elements in a queue in chat rooms
If the element added by User A is updated by User B, the owner of the element is User B.
URL
httpPOST https://api.netease.im/nimserver/chatroom/queueBatchUpdateElements.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
- For information about the header in a POST request, see Overview.
- The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | long | Yes | Chat room ID |
operator | String | Yes | Operator account ID, must be administrator or creator |
elements | String | Yes | Updated key-value pairs, up to 200 pairs, example: {"k1":"v1","k2":"v2"}. |
needNotify | boolean | No | whether notifications are sent for update events, The default value is true. |
notifyExt | String | No | Extension field for notification events, up to 2,048 characters |
Example
Example request (cURL)
curlcurl -X POST -H 'appkey: fe4166***47ad2547' -H 'cache-control: no-cache' -H 'checksum: 18f5435a***75265495034' -H 'content-type: application/x-www-form-urlencoded' -H 'curtime: 1508481877' -H 'nonce: 12345' -d 'roomid=18&operator=xiaoming01&elements=%7b%22k1%22%3a%22v1%22%2c%22k2%22%3a%22v2%22%7d' "https://api.netease.im/nimserver/chatroom/queueBatchUpdateElements.action"
Response
json
"Content-Type": "application/json; charset=utf-8"
{
"code": 200,
"desc":{
"noExistElementKey":[
"k1"
]
}
}
List all elements in a queue
URL
httpPOST https://api.netease.im/nimserver/chatroom/queueList.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
- For information about the header in a POST request, see Overview.
- The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | long | Yes | Chat room ID |
Example
Example request (cURL)
curlcurl -X POST -H "CheckSum: 37dc87d***kbf049c9367e7" -H "AppKey: fe416640c8e8a7***47ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&key=1111' "https://api.netease.im/nimserver/chatroom/queueList.action"
Response
json"Content-Type": "application/json; charset=utf-8"
{
"desc": {
"list": [
{
"33333": "33333"
}
]
},
"code": 200
}
Get elements from a queue
URL
httpPOST https://api.netease.im/nimserver/chatroom/queuePoll.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
- For information about the header in a POST request, see Overview.
- The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | long | Yes | Chat room ID |
key | String | No | The elementKey of an element, up to 128 characters. If unspecified, get the first element of a queue. |
Example
Example request (cURL)
curlcurl -X POST -H "CheckSum: 37dc1***9bbf049c9367e7" -H "AppKey: fe416***19e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451200147" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&key=333334444' "https://api.netease.im/nimserver/chatroom/queuePoll.action"
Response
json"Content-Type": "application/json; charset=utf-8"
{
"desc": {
"value": "66666",
"key": "1111"
},
"code": 200
}
Get elements of a specified queue
Get elements of a specified queue by element key.
URL
httpPOST https://api.netease.im/nimserver/chatroom/queueMultiGet.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
- For information about the header in a POST request, see Overview.
- The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | long | Yes | Chat room ID |
keys | JSONArray | Yes | List of element keys to be queried, up to 100, example: ["key1","key2","key3"] |
Example
Example request (cURL)
curlcurl -X POST -H 'appkey: fe4***d2547' -H 'cache-control: no-cache' -H 'checksum: 18f5***65495034' -H 'content-type: application/x-www-form-urlencoded' -H 'curtime: 1508481877' -H 'nonce: 12345' -d 'roomid=64&keys=%5B%22key1%22%2C%22key2%22%2C%22key3%22%5D' "https://api.netease.im/nimserver/chatroom/queueMultiGet.action"
Response
json
"Content-Type": "application/json; charset=utf-8"
{
"code": 200,
"desc": {
"list": [
{
"key1": "value1"
},
{
"key2": "value2"
},
{
"key3": "value3"
}
]
}
}
Status codes
The status code is returned in the response body. For more information, see Status codes.
Was this page helpful?