钉钉如何请求webhook发送信息

代码:js

复制代码
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

const raw = JSON.stringify({
  "at": {
    "atMobiles": [
      "180xxxxxx"
    ],
    "atUserIds": [
      "user123"
    ],
    "isAtAll": false
  },
  "text": {
    "content": "我就是我, @user123 是不一样的烟火"
  },
  "msgtype": "text"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://oapi.dingtalk.com/robot/send?access_token=a20fc884379fd76bd27ad902fc7ec940f1c1573a3b468852372091474", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

代码axios

复制代码
const axios = require('axios');
let data = JSON.stringify({
  "at": {
    "atMobiles": [
      "180xxxxxx"
    ],
    "atUserIds": [
      "user123"
    ],
    "isAtAll": false
  },
  "text": {
    "content": "我就是我, @user123 是不一样的烟火"
  },
  "msgtype": "text"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://oapi.dingtalk.com/robot/send?access_token=a20fc884379fd76bd27ad902fc7ec940f1c1573a3b468852372091474',
  headers: { 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});
相关推荐
zandy10112 天前
衡石科技chatbot分析手册--钉钉数据问答机器人配置
科技·机器人·钉钉·chatbot·衡石科技
JAVA拾贝2 天前
Prometheus+Grafana运维监控并实现钉钉告警
运维·钉钉·grafana·prometheus·运维监控
yunson_Liu14 天前
服务器获取外网IP,并发送到钉钉
服务器·钉钉
lgbisha17 天前
华为云Flexus+DeepSeek征文|体验华为云ModelArts快速搭建Dify-LLM应用开发平台并创建自己dify钉钉群聊机器人
人工智能·ai·语言模型·自然语言处理·机器人·华为云·钉钉
LUCIAZZZ20 天前
钉钉机器人-自定义卡片推送快速入门
java·jvm·spring boot·机器人·钉钉·springboot
知行EDI1 个月前
知行之桥如何将消息推送到钉钉群?
钉钉·edi·电子数据交换·知行软件·知行edi
张_boss1 个月前
Ubuntu Zabbix 钉钉报警
ubuntu·钉钉·zabbix
xiaogai_gai1 个月前
钉钉通讯录与金蝶云星空无缝集成的技术实现方法
大数据·数据库·钉钉
少可爱1 个月前
对接钉钉消息样例:DING消息、机器人
java·开发语言·钉钉