钉钉如何请求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);
});
相关推荐
jingwang-cs11 小时前
内外网隔离文件传输解决方案|系统与钉钉集成+等保合规,安全提升70%
安全·中间件·钉钉·安全架构
zy2152153 天前
钉钉机器人开发实战:快速实现消息通知自动化
机器人·自动化·钉钉
精神病研究院王主任3 天前
钉钉应用开发
钉钉
m0_621966014 天前
一键部署开源DeepSeek并集成到钉钉
开源·大模型·钉钉
x-cmd5 天前
[250217] x-cmd 发布 v0.5.3:新增 DeepSeek AI 模型支持及飞书/钉钉群机器人 Webhook 管理
ai·机器人·llm·钉钉·飞书·webhook·deepseek
骑着蜗牛ひ追导弹'10 天前
【办公】钉钉修改默认存储位置,释放C盘空间
钉钉
光芒再现039413 天前
基于钉钉API的连接器实现:企业数据集成与自动化管理
数据库·自动化·钉钉
大数据技术架构13 天前
构建您的专属AI助手:在钉钉上部署DeepSeek
人工智能·钉钉
Tassel_YUE20 天前
Zabbix 推送告警 消息模板 美化(钉钉Webhook机器人、邮件)
机器人·钉钉·zabbix
linab11223 天前
springboot集成钉钉,发送钉钉日报
钉钉