注册

群面员禁言、或全局禁言总是返回400

//访问地址 /{org_name}/{app_name}/chatgroups/{group_id}/mute
String url = MessageFormat.format("{0}/chatgroups",
HuanxinImSecurityConfig.getHuanxinUrl()
);
url = url + "/" + cmd.getTid() + "/mute";

HuanxinAdminTokenInfo tokenInfo = HuanxinAdminTokenUtil.findHuanxinAdminToken();
try {
//Bearer
String token = "Bearer " + tokenInfo.getAccess_token();

// JSONArray body = new JSONArray();
JSONObject jsonObject = new JSONObject();
//要被添加禁言用户的 ID"usernames":["user1"]
jsonObject.put("usernames", cmd.getAccid());
//禁言的时间,单位毫秒,如果是“-1”代表永久(实际的到期时间为固定时间戳4638873600000,即2117-01-01 00:00:00
jsonObject.put("mute_duration", 86400000);
// body.add(jsonObject);

HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", token);
//headers.setContentType(MediaType.APPLICATION_JSON);
//headers.setConnection();
MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
// 请勿轻易改变此提交方式,大部分的情况下,提交方式都是表单提交
headers.setContentType(type);
HttpEntity httpEntity = new HttpEntity(jsonObject.toString(), headers);
ResponseEntity responseEntity = restTemplate.postForEntity(url, httpEntity, null);
return responseEntity.getStatusCodeValue() == HttpStatus.SC_OK;
已邀请:

yangjian - 90后闷骚男

一般报400是因为你请求语法或者数据格式是有问题的.

你这个使用postman尝试一下吧,如果postman能调通的话,再转入代码中试试.

添加禁言

/{org_name}/{app_name}/chatgroups/{group_id}/mute
和解除禁言是可以了,谢谢您的回复!
设置用户全局禁言
设置单个帐号的单聊、群组、聊天室消息全局禁言。

基本信息

请求方法:POST

接入点: /{orgName}/{appName}/mutes

当对群设置全局禁言时出现下面的提示--在postman中
{

"error": "required_property_not_found",
"exception": "RequiredPropertyNotFoundException",
"timestamp": 1645694207462,
"duration": 0,
"error_description": "Entity user requires a property named username"
}   

提交的数据为:
{
    "username":"173652341489665",
    "chat"100,
    "groupchat"2147483647,
    "chatroom"100
}
当对某用户设置全局禁言时,出现下面的提示--在postman中

{
"error": "forbidden_op",
"exception": "EasemobForbiddenOpException",
"timestamp": 1645694442120,
"duration": 0,
"error_description": "user_mute is not used for this app"
}

能帮我再看下原因吗,谢谢









要回复问题请先登录注册