钉钉如何请求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);
});
相关推荐
陌陌6232 天前
Clawdbot接入钉钉 / Moltbot接入钉钉
钉钉·clawdbot
Yolanda943 天前
【项目经验】钉钉免密登录实现
前端·javascript·钉钉
Yolanda943 天前
【教程技巧】钉钉自定义机器人新建及url获取流程
机器人·钉钉
gjxDaniel6 天前
钉钉是什么?
钉钉·生活
AITOP1008 天前
钉钉8.2.5版本上线 “AI 差旅”,携手高德支付宝实现智能比价与免垫资
钉钉·钉钉ai差旅·aitop100
光锥智能9 天前
飞书钉钉AI硬件争夺战:录音背后的入口之争
人工智能·钉钉·飞书
kkoral9 天前
【FFmpeg 智慧园区场景应用】5.企业微信 / 钉钉告警一键切换脚本(含静默周期 + 恢复通知)
ffmpeg·钉钉·企业微信
kkoral9 天前
【FFmpeg 智慧园区场景应用】4.企业微信 / 钉钉机器人告警配置(替换邮件告警)
ffmpeg·钉钉·企业微信
季布,12 天前
本地Windows测试:钉钉群消息/文件传输到Python服务(完整教程)
windows·python·钉钉
右手 无名指13 天前
Github Actions工作流配置webhook推送到钉钉机器人
机器人·github·钉钉