当前位置: 首页 > article >正文

钉钉如何请求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);
});


http://www.kler.cn/news/327764.html

相关文章:

  • 基于JAVA+SpringBoot+Vue的校园商铺管理系统
  • Java之线程篇七
  • 解读 Story Protocol:IP 与区块链的潜力与障碍
  • 从零开始Ubuntu24.04上Docker构建自动化部署(四)Docker安装gitlab
  • 微信小程序转化为uni-app项目
  • 这个科技工厂藏着拼多多的「数字田园梦」
  • OpenHarmony(鸿蒙南向)——平台驱动指南【PWM】
  • 学Java还是c++好?
  • 如何在字节跳动的marscode上部署AI API,却意外地将功能搞废了?——分享踩坑经历
  • SpringCloud源码:服务端分析(二)- EurekaServer分析
  • 滚雪球学Oracle[1.1讲]:Oracle数据库基础概念
  • RabbitMQ高级特性-发送方确认
  • 使用scroll-behavior属性实现页面平滑滚动的几个问题
  • 力扣经典笔试题 最小K个数 小根堆 大根堆 快速排序 一题多解
  • C语言初识(二)
  • Springboot项目实现easyExcel批量导入到数据库
  • Python人工智能使用OpenCV进行图片形状的中心检测
  • linux 查看端口占用
  • 利用SpringBoot构建高效社区医院平台
  • 大数据埋点方案Openresty+Nginx+Lua踩坑日志
  • QSpice (9) --结合Python仿真
  • PostgreSQL是否有等待事件
  • Android常用C++特性之std::abs
  • Clickhouse分布式表初体验
  • python的内存管理机制
  • DOM元素导出图片与PDF:多种方案对比与实现
  • 数据集-目标检测系列-豹子 猎豹 检测数据集 leopard>> DataBall
  • 线程池:线程池的实现 | 日志
  • 普通人如何在未来市场中寻找赚钱机会?
  • 深信服2025届全球校招研发笔试-C卷(AK)