钉钉如何请求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);
});
相关推荐
东方巴黎~Sunsiny5 小时前
java项目实现钉钉异常告警实时监控
java·开发语言·钉钉
Alter123020 小时前
钉钉x昇腾:用AI一体机撬动企业数字资产智能化
人工智能·钉钉
国通快递驿站2 天前
AntFlow-Vue3 :一个仿钉钉流程审批,且满足99.8%以上审批流程需求的企业级工作流平台,开源且免费!
java·spring·spring cloud·开源·钉钉·工作流·审批流
是潮汕的灿灿展吖3 天前
钉钉H5微应用Springboot+Vue开发分享
spring boot·钉钉
恋上钢琴的虫4 天前
使用docker形式部署prometheus+alertmanager+钉钉告警
docker·钉钉·prometheus
钉钉项目Teambition5 天前
Jira Cloud涨价5%-20%,钉钉项目Teambition成优选替代
钉钉·jira·teambition
Dragon_qu·x5 天前
shell脚本定时任务通知到钉钉
linux·运维·自动化·钉钉
Java_2017_csdn5 天前
钉钉群-推送消息-Java
钉钉
yunson_Liu8 天前
编写Python脚本在证书过期10天内将域名信息发送到钉钉
开发语言·python·钉钉