sql server钉钉推送markdown消息

/**

启用 Ole Automation Procedures 选项
exec sp_configure 'show advanced options',1;
go
reconfigure;
go
sp_configure 'Ole Automation Procedures',1;
go
reconfigure;
go
*/
declare @PostData nVARCHAR(max) = '' , @ResponseText VARCHAR(max) = ''
DECLARE @ServiceUrl AS VARCHAR(1000)
set @ServiceUrl = N'https://oapi.dingtalk.com/robot/send?access_token=*****0'
set @PostData = N'{"msgtype": "markdown", "markdown": {
"title":"机器人",
"text": "
### 通知\n
来自**机器人**的通知
" } }'

DECLARE @Object AS INT ,
@status INT ,
@returnText AS VARCHAR(8000) ,
@HttpStatus VARCHAR(200) ,
@HttpMethod VARCHAR(20) = 'post'


EXEC @status = sp_OACreate 'Msxml2.ServerXMLHTTP.3.0', @Object OUT;

EXEC @status = sp_OAMethod @Object, 'open', NULL, @HttpMethod, @ServiceUrl, 'false'

EXEC @status = sys.sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type', 'application/json; charset=UTF-8'

EXEC @status = sp_OAMethod @Object, 'send', NULL, @PostData

EXEC @status = sys.sp_OAGetProperty @Object, 'Status', @HttpStatus OUT;

EXEC @status = sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT

EXEC @status = sp_OADestroy @Object
print @ResponseText

posted @   感生  阅读(25)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示