钉钉如何请求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);
});
相关推荐
医疗信息化王工2 天前
钉钉小程序开发实战:投诉管理系统
小程序·钉钉·开发·投诉管理
医疗信息化王工3 天前
钉钉小程序开发实战:手术查询小程序
小程序·钉钉·手术查询
二进喵3 天前
OpenClaw 接入钉钉完整指南
钉钉
Teable任意门互动3 天前
多维表格本地化部署实践解析 企业如何实现数据自主可控路径
数据库·excel·钉钉·飞书·开源软件
水文摸鱼怪5 天前
HHU校园网自动连接监控系统(钉钉机器人版)操作说明书
机器人·钉钉
QDYOKR1685 天前
一文了解什么是OKR
大数据·人工智能·笔记·钉钉·企业微信
MarkHD6 天前
从“能跑”到“好用”:Python脚本监控与告警实战(邮件/钉钉/企业微信)
python·钉钉·企业微信
liangdabiao7 天前
[开源]钉钉CLI上10个APP - skills适合使用 openclaw - 养龙虾
钉钉
weixin_4493108411 天前
实现钉钉报销到金蝶付款单的技术方案
钉钉
WeskyNet12 天前
Claude Code钉钉双向交互集成
钉钉