钉钉如何请求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);
});
相关推荐
知行EDI7 天前
知行之桥如何将消息推送到钉钉群?
钉钉·edi·电子数据交换·知行软件·知行edi
张_boss8 天前
Ubuntu Zabbix 钉钉报警
ubuntu·钉钉·zabbix
xiaogai_gai13 天前
钉钉通讯录与金蝶云星空无缝集成的技术实现方法
大数据·数据库·钉钉
少可爱15 天前
对接钉钉消息样例:DING消息、机器人
java·开发语言·钉钉
louisliao_198118 天前
钉钉开发之AI消息和卡片交互开发文档收集
人工智能·钉钉
lijian26018 天前
钉钉手机端应用访问提示: 钉钉授权码获取遇到了 “签名校验失败“ 的错误,钉钉开发文档有坑造成的
钉钉
云中计算巫作坤20 天前
U9C与钉钉审批流对接完整过程
钉钉·u9c·集成对接
集成显卡20 天前
网页 H5 微应用接入钉钉自动登录
前端·后端·钉钉
dianzouyou12345620 天前
钉钉报销与金蝶付款单系统对接技术揭秘
大数据·数据库·钉钉