钉钉如何请求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);
});
相关推荐
白白白鲤鱼12 天前
Vue2项目—基于路由守卫实现钉钉小程序动态更新标题
服务器·前端·spring boot·后端·职场和发展·小程序·钉钉
后青春期的诗go12 天前
对接钉钉审批过程记录(C#版本)
钉钉·钉钉对接·流程对接·钉钉流程对接
yidiancaijing24 天前
钉钉换帅后,先砍自己人
钉钉
Wezzer24 天前
Zabbix告警系统集成指南:从钉钉机器人到网易邮件的全流程配置
运维·钉钉·zabbix·触发器·网易邮箱
Better Rose24 天前
2025年“创新杯”(原钉钉杯) A题 建模思路
人工智能·数学建模·钉钉
钉钉开发者社区24 天前
AI开放课堂:钉钉MCP开发实战
人工智能·钉钉
热心网友俣先生24 天前
20255年第四届创新杯(原钉钉杯)参考论文+标准答案发布
钉钉
CZZDg24 天前
zabbix自动发现、自动注册、及自动预警到邮箱
钉钉·zabbix
Layux25 天前
使用钉钉开源api发送钉钉工作消息
java·spring boot·钉钉
yuzx20081 个月前
ubuntu 24.04 xfce4 钉钉输入抢焦点问题
linux·ubuntu·钉钉