我在使用微信的公众号API上传其他类型的永久素材时,错误代码41005,提示'media data missing hint: [13z660413w596] rid: 644a141c-7e1c4827-335023e2',python代码如下,请问该如何修正
def get_image_id(self, filepath) -> str:
url = f"https://api.weixin.qq.com/cgi-bin/material/add_material?access_token={self.access_token}&type=thumb"
# url = f"https://api.weixin.qq.com/cgi-bin/media/upload?access_token={self.access_token}&type=image"
files = {
"media": open(filepath, "rb")
}
print(files)
resp = requests.post(url, files=files)
result = resp.json()
if 'media_id' in result:
return result["media_id"]
else:
print(result)