首页 > 其他分享 >{"errcode":40033,"errmsg":"invalid charset. please check your request, if i

{"errcode":40033,"errmsg":"invalid charset. please check your request, if i

时间:2023-02-25 14:01:07浏览次数:39  
标签:utf name data charset request json https include type


问题

​{"errcode":40033,"errmsg":"invalid charset. please check your request, if include \\uxxxx will create fail! hint: [FISJMa0799shc2]"}​

解决方案:

最重要的一句话:

json.dumps(parameters, ensure_ascii=False).encode('utf-8')

完整代码如下

urlstr = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + access_token
parameters = {
"button":[
{
"type": "scancode_push",
"name": "扫码打印",
"key": "rselfmenu_0_1",
"sub_button": [ ]
},
{
"name":"个人中心",
"sub_button":[
{
"type":"view",
"name":"我的订单",
"url":"https://injiajia.telabytes.com/"
},
{
"type":"view",
"name":"在校兼职",
"url":"https://injiajia.telabytes.com/"
}
]
}]
}
param_jsonstr = json.dumps(parameters, ensure_ascii=False).encode('utf-8')
http = urllib3.PoolManager()
response = http.request("POST",
urlstr,
headers={'Content-Type' : 'application/json'},
body=param_jsonstr)
resp_data = str(response.data, encoding="utf-8")
print(resp_data)


标签:utf,name,data,charset,request,json,https,include,type
From: https://blog.51cto.com/u_14062833/6085443

相关文章