钉钉如何请求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);
});
相关推荐
岚天start1 天前
【日志监控方案】Python脚本获取关键字日志信息并推送钉钉告警
python·钉钉·日志监控
科技快报11 天前
钉钉开源HarmonyOS图片编辑组件:四大核心功能直击图片编辑痛点
开源·钉钉·harmonyos
就叫飞六吧13 天前
钉钉开发“待办“接口版本调研
钉钉
就叫飞六吧13 天前
钉钉“待办“相关接口调研列表
钉钉
就叫飞六吧13 天前
钉钉企业内部应用 SSO 免登集成实战 (Spring Boot 版)
java·spring boot·钉钉
Teable任意门互动14 天前
从飞书多维表格 简道云到Teable多维表格:企业为何选择Teable作为新一代智能数据协作平台?
数据库·excel·钉钉·飞书·开源软件
就叫飞六吧14 天前
三步搭建“钉钉待办推送” (curl版)+工作通知
数据库·redis·钉钉
蓝鲨硬科技15 天前
“硬”气的钉钉
钉钉
成为你的宁宁16 天前
【Jenkins添加钉钉通知】
jenkins·钉钉
光锥智能17 天前
钉钉发布全球首个工作智能操作系统Agent OS,重构AI时代的工作方式
人工智能·重构·钉钉