
调用微信新增临时素材报invalid media type hint
def test_file_upload(self):
url = f'https://api.weixin.qq.com/cgi-bin/media/upload?access_token={TestsSndRequest.access_token}&type="image"'
data = {
"media": open(r'zfb.png', 'rb')
}
rep = requests.post(url=url, files=data)
print(rep.json())

解决办法如下,type需要通过data传参:
import pytest as pytest
import requests
class TestsSndRequest:
access_token = ''
def test_get_token(self):
url = 'https://api.weixin.qq.com/cgi-bin/token'
data = {
"grant_type": "client_credential",
"appid": appID,

在使用Python进行微信自动化过程中,遇到调用接口新增临时素材时返回'invalid media type hint'错误。经过排查,发现解决方案在于通过data参数传递正确的素材类型。
最低0.47元/天 解锁文章
3234

被折叠的 条评论
为什么被折叠?



