开发者社区> 问答> 正文

企业会话消息接口调用返回系统繁忙-1

我使用的是JAVA语言,请求代码如下



@RequestMapping(value = "/dingding/send.json")
public void send(HttpServletRequest request, HttpServletResponse response, Model model) {
String accessToken = request.getParameter("access_token");
String agentid = request.getParameter("agentid");
try {
URL url = new URL("https://oapi.dingtalk.com/message/send?access_token=" + accessToken);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.connect();
// POST请求
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
JSONObject obj = new JSONObject();
obj.put("agentid", agentid);
obj.put("toparty", "33461803");
obj.put("touser", "manager7432");
obj.put("msgtype", "text");
obj.put("text", new Text("测试消息"));

out.writeBytes(obj.toJSONString());
out.flush();
out.close();

// 读取响应
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String lines;
StringBuffer sb = new StringBuffer("");
while ((lines = reader.readLine()) != null) {
lines = new String(lines.getBytes(), "utf-8");
sb.append(lines);
}
System.out.println(sb);
reader.close();
// 断开连接
connection.disconnect();
} catch (Exception e) {
} finally {
}
}




参数如下:
{"agentid":"89452256","msgtype":"text","text":{"content":"测试消息"},"toparty":"33461803","touser":"manager7432"}


控制台返回参数如下:
{"errmsg":"系统繁忙","errcode":-1}


调用visible_scopes接口时传agentid时可以成功返回微应用相关信息

展开
收起
天卜 2017-04-11 12:55:45 2395 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
面向失败设计 立即下载
探索连接的最后十秒”落时”的网关 立即下载
低代码开发师(初级)实战教程 立即下载