收藏
回答

C#小程序直播商品添加并提审goodsInfo must not be empty?

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(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);

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.d__5`1.MoveNext()

--- 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”


回答关注问题邀请回答
收藏
登录 后发表内容
问题标签