C#代码:
return await Senparc.Weixin.MP.ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format("https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token={0}", accessToken.AsUrlData());
var result = await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync
return result;
}, accessTokenOrAppId);
使用微信组件中的接口await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync提交数据报错
返回错误提示:
微信 POST 请求发生错误!错误代码:200002,说明:goodsInfo must not be empty rid: 5f35f1cb-7b7421a2-7b5d885a
Senparc.Weixin.Exceptions.ErrorJsonResultException: 微信 POST 请求发生错误!错误代码:200002,说明:goodsInfo must not be empty rid: 5f35f1cb-7b7421a2-7b5d885a
在 Senparc.Weixin.CommonAPIs.CommonJsonSend.<>c.<.cctor>b__6_1(String apiUrl, String returnText)
在 Senparc.CO2NET.HttpUtility.Post.
--- End of stack trace from previous location where exception was thrown ---
原因:
Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync提交表单数据时默认Header中的ContentType是text/xml
解决方案:
需要自己另外封装接口设置 request.ContentType =“application/json; charset=UTF-8”