- 当前 Bug 的表现(可附上截图)
wx.request 设置content-type 为multipart/form-data ,请求头如下:
POST /mindoffice/visitor_unreservations/subscribeBill HTTP/1.1 Host: qas.zjzlnet.com Content-Length: 20 Pragma: no-cache Cache-Control: no-cache Origin: http://127.0.0.1:34785 User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1 wechatdevtools/1.02.1809111 MicroMessenger/6.5.7 Language/zh_CN webview/ token/61f11dc1d5bc1cfd264bbe33ae8d2f95 content-type: multipart/form-data Accept: */* Referer: https://servicewechat.com/wx04c25e121b8ce5df/devtools/page-frame.html Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.8 Connection: keep-alive {"data":"test data"} |
提交的参数没有被 boundary 包裹,后台拒绝了请求,提示 no multipart boundary was found
- 预期表现
POST /mindoffice/visitor_unreservations/subscribeBill HTTP/1.1 Content-Type: multipart/form-data; boundary=7f81e6d3-da78-4610-82b5-b4906d630ab3 Content-Length: 407 Host: 115.29.7.124 Accept-Encoding: gzip User-Agent: okhttp/3.6.0 Connection: keep-alive --7f81e6d3-da78-4610-82b5-b4906d630ab3 content-disposition: form-data; name="data" Content-Length: 255 test data --7f81e6d3-da78-4610-82b5-b4906d630ab3-- |
wx.uploadFile支持 multipart/form-data,但是我这个接口不需要传文件,只需传键值对,就是这么奇怪。。
请问该怎么解决呢?谢谢~
可以的。https://developers.weixin.qq.com/community/develop/article/doc/0000cc0e5bc5d093c6f8be17254c13
既然不需要传文件,那后台就不要用文件上传的方式来接收请求参数呗。
对啊,但是后台就是这么奇怪的写的接口,烦。。
ps: app端是可以这样传的。。
难怪,后台不是你自己写的啊!