钉钉如何请求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);
});
相关推荐
皮皮虾❀5 小时前
企业协同办公平台深度对比:钉钉、飞书、企微的区别与钉钉服务商典铭云赛推荐
钉钉·飞书·企业微信
皮皮虾❀5 天前
专属钉钉定制开发需要多少钱?2026年费用构成方案
钉钉
皮皮虾❀5 天前
钉钉AI算粒收费后,如何零成本搭建专属钉钉智能体?
人工智能·钉钉
数聚天成DeepSData5 天前
内网多人在线填表自动汇总系统搭建:飞书钉钉与开源Baserow、NocoDB方案
开源·钉钉·飞书
xixingzhe25 天前
与钉钉机器人交互通信
钉钉
皮皮虾❀5 天前
典名科技:钉钉六星级钻石服务商
科技·钉钉
微学AI5 天前
内网穿透的应用-服务器日志出现异常怎么办?Python监控、钉钉告警与远程处理教程
服务器·python·钉钉
yyxx4121236 天前
金蝶和钉钉怎么打通?
钉钉
晨陌y7 天前
多台服务器怎么统一监控?哪吒面板部署、钉钉告警与远程访问教程
运维·服务器·钉钉
北极糊的狐14 天前
钉钉小程序 Git 版本管理完整流程
git·小程序·钉钉