BUG如下
三月 07, 2022 10:28:52 下午 topsdk logApiError
严重: 2022-03-07 22:28:52.638^_^_dingtalk_^_^dingtalk.oapi.robot.send^_^172.22.192.106^_^Mac OS X^_^475^_^https://oapi.dingtalk.com/robot/send?access_token=38524de10a37cf0394f987f9924f36220f69111509dd9236032f8b3255057971^_^link=%7B%22messageUrl%22%3A%22http%3A%5C%2F%5C%2Fsam01%3A8081%22%2C%22picUrl%22%3A%22%22%2C%22text%22%3A%22%E8%BF%99%E6%98%AF%E6%88%91%E5%8F%91%E7%9A%84%E7%AC%AC%E4%B8%80%E6%9D%A1%E9%92%89%E9%92%89%E6%B6%88%E6%81%AF%22%2C%22title%22%3A%22ding+talk+test%22%7D&msgtype=link^_^{"errcode":310000,"errmsg":"keywords not in content, more: [https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq]"}
原代码:
package com.sam;
import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.taobao.api.ApiException;
public class DingDingTalkTest {
public static void main(String[] args) throws ApiException {
String token = "38524de10a37cf0394f987f9924f36220f69111509dd9236032f8b3255057971";
DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=" + token);
OapiRobotSendRequest request = new OapiRobotSendRequest();
request.setMsgtype("link");
OapiRobotSendRequest.Link link= new OapiRobotSendRequest.Link();
link.setMessageUrl("http://sam01:8081");
link.setPicUrl("");
link.setTitle("ding talk test");
link.setText("这是我发的第一条钉钉消息");
request.setLink(link);
try{
client.execute(request);
} catch (ApiException e){
e.printStackTrace();
}
}
}
解决方法:在发送的消息那添加设置的关键词
在钉钉app查看机器人的关键词
![image](https://img2022.cnblogs.com/blog/1306833/202203/1306833-20220307223302209-57172905.png)
代码中添加关键词
![image](https://img2022.cnblogs.com/blog/1306833/202203/1306833-20220307223439129-1288586019.png)