当前位置:网站首页>{“errcode“:44001,“errmsg“:“empty media data, hint: [1655962096234893527769663], from ip: 222.72.xxx.
{“errcode“:44001,“errmsg“:“empty media data, hint: [1655962096234893527769663], from ip: 222.72.xxx.
2022-07-27 03:06:00 【big__ apple】
{"errcode":44001,"errmsg":"empty media data, hint: [1655962096234893527769663], from ip: 222.72.xxx.246, more info at https://open.work.weixin.qq.com/devtool/query?e=44001"}
platform
Windows Enterprise WeChat ( Enterprise wechat group robot )
Language :Python
Cause of error
Upload url And sent url Used the same api
Try to plan
1、 to update urllib3 and requests Version of , Doesn't work
2、 View online on boundary After add \r\n, It feels too complicated , And the official documents do not use this scheme , You can have a look at what you are interested in , However, when I succeed here, I make a judgment , This plan doesn't work ( In this case I encountered ), Attach address (https://blog.csdn.net/xuexiaodong009/article/details/83081911)
In addition, there are basically only the above two types of online solutions , If the following method fails after trying , You can check the two schemes mentioned above .
Error code
def sent_to_work_wechat(file_path=None):
"""
Upload files to the enterprise wechat announcement Group
Parma file_path: Upload file path
"""
if not file_path:
# file_path = './2022-07-18-tonggao_log.txt'
file_path = f'{get_time_of_timestamp()}-tonggao_log.txt'
# Announcement platform Number of announcements Group robots
robot_curl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=9df679e-1352-4663-bc22-69e82662c9c1"
upload_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=9df679e-1352-4663-bc22-69e82662c9c1&type=file"
data = {'file': open(file_path, 'rb')}
resp = requests.post(upload_url, files=data)
json_res = resp.json()
logger.info(f" The enterprise wechat robot uploaded the file successfully ,file:{file_path}")
post_data = {
"msgtype": "file",
"file": {"media_id": json_res.get('media_id')}
}
headers = {'Content-Type': 'application/json'}
resp = requests.post(url=robot_curl, headers=headers, json=post_data)
logger.info(f"response: {resp.text}")
Success code
def sent_to_work_wechat(file_path=None):
"""
Upload files to the enterprise wechat announcement Group
Parma file_path: Upload file path
"""
if not file_path:
# file_path = './2022-07-18-tonggao_log.txt'
file_path = f'{get_time_of_timestamp()}-tonggao_log.txt'
# Announcement platform Number of announcements Group robots
robot_curl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=9df679e-1352-4663-bc22-69e82662c9c1"
upload_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=9df679e-1352-4663-bc22-69e82662c9c1&type=file"
data = {'file': open(file_path, 'rb')}
resp = requests.post(upload_url, files=data)
json_res = resp.json()
logger.info(f" The enterprise wechat robot uploaded the file successfully ,file:{file_path}")
post_data = {
"msgtype": "file",
"file": {"media_id": json_res.get('media_id')}
}
headers = {'Content-Type': 'application/json'}
resp = requests.post(url=robot_curl, headers=headers, json=post_data)
logger.info(f"response: {resp.text}")
difference
At that time, the code that went wrong was uploading and sending files url On , Because the parameters were confused ( The robe giggled : Hiccup, hiccup, Hiccup )
So if this problem occurs , Please check whether the common parameters are normal , for example url
边栏推荐
猜你喜欢
![[nisactf 2022] upper](/img/61/05291ba7a63fe13882e49ab026df14.png)
[nisactf 2022] upper

Kubernetes dashboard deployment application and access

vs2019 中编译和使用 protobuf 库

Arduinouno drive RGB module full color effect example

Time module: acquisition and mutual transformation of timestamp, structured time and formatted time

对象创建的流程分析

Okaleido Tiger 7.27日登录Binance NFT,首轮已获不俗成绩

OD-Paper【3】:Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks

B-树的应用以及添加和删除操作

一道数学题,让芯片巨头亏了5亿美金!
随机推荐
Is the low commission account opening of Galaxy Securities Fund reliable, reliable and safe
Quick sort
Blog competition dare to try BAC for beginners
Ansible series: do not collect host information gather_ facts: False
云开发寝适闹钟微信小程序源码
用最原始的方法纯手工实现常见的 20 个数组方法
Thread.Sleep(0)的作用
[untitled]
Kubernetes dashboard deployment application and access
基于.NetCore开发博客项目 StarBlog - (16) 一些新功能 (监控/统计/配置/初始化)
Comprehensive summary of shell analysis log file commands
Concept of data asset management
LabVIEW中编程更改进程的优先级
Debezium系列之:基于debezium offset拉取历史数据,确保数据没有丢失
商城小程序项目完整源码(微信小程序)
Web3.0 world knowledge system sharing - what is Web3.0
#博客大赛# 斗胆尝试浅入门之BAC
Leetcode- > binary search clock in
面试突击68:为什么 TCP 需要 3 次握手?
制作ppt时间轴