钉钉如何请求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);
});
相关推荐
zandy10114 天前
AI驱动全球销售商机管理:钉钉DingTalk A1的跨域管理智能解决方案
人工智能·百度·钉钉
feng一样的男子5 天前
阿里云的moltbot机器人使用钉钉的Stream流式接入
阿里云·机器人·钉钉
Honmaple5 天前
OpenClaw 钉钉插件安装指南
服务器·网络·钉钉
陌陌62310 天前
Clawdbot接入钉钉 / Moltbot接入钉钉
钉钉·clawdbot
Yolanda9411 天前
【项目经验】钉钉免密登录实现
前端·javascript·钉钉
Yolanda9411 天前
【教程技巧】钉钉自定义机器人新建及url获取流程
机器人·钉钉
gjxDaniel14 天前
钉钉是什么?
钉钉·生活
AITOP10016 天前
钉钉8.2.5版本上线 “AI 差旅”,携手高德支付宝实现智能比价与免垫资
钉钉·钉钉ai差旅·aitop100
光锥智能17 天前
飞书钉钉AI硬件争夺战:录音背后的入口之争
人工智能·钉钉·飞书
kkoral17 天前
【FFmpeg 智慧园区场景应用】5.企业微信 / 钉钉告警一键切换脚本(含静默周期 + 恢复通知)
ffmpeg·钉钉·企业微信