群面员禁言、或全局禁言总是返回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;
没有找到相关结果
已邀请:
2 个回复
yangjian - 90后闷骚男
一般报400是因为你请求语法或者数据格式是有问题的.
你这个使用postman尝试一下吧,如果postman能调通的话,再转入代码中试试.
丰
添加禁言
基本信息
请求方法:POST
接入点: /{orgName}/{appName}/mutes
"error": "required_property_not_found",
"exception": "RequiredPropertyNotFoundException",
"timestamp": 1645694207462,
"duration": 0,
"error_description": "Entity user requires a property named username"
}
{
"error": "forbidden_op",
"exception": "EasemobForbiddenOpException",
"timestamp": 1645694442120,
"duration": 0,
"error_description": "user_mute is not used for this app"
}
能帮我再看下原因吗,谢谢