C#小程序直播商品添加并提审goodsInfo must not be empty?
发布于 6 年前 作者 fangxia 10021 次浏览 来自 问答

C#代码:

return await Senparc.Weixin.MP.ApiHandlerWapper.TryCommonApiAsync(async accessToken =>

{

var urlFormat = string.Format("<a href="https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=" rel="noopener noreferrer" target="_blank">https://api.weixin.qq.com/wxaapi/broadcast/room/create?access\_token=</a>{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”

回到顶部