Skip to content

微信公众号,素材上传经过Java写的代理服务器出现:the request was rejected because no multipart boundary was found #3273

Closed
@Minhat-GitHub

Description

@Minhat-GitHub

简要描述

微信公众号,素材上传如果直接传给微信可以成功;如果走Java写的Controller代理服务器会出现:
the request was rejected because no multipart boundary was found

经过排查是因为:
MaterialUploadApacheHttpRequestExecutor.execute()方法中63行:
httpPost.setHeader("Content-Type", ContentType.MULTIPART_FORM_DATA.toString());

因为Tomcat处理上传文件时需要请头Content-Type为multipart/form-data; boundary=--------------------------242815868904497413282610

但是MaterialUploadApacheHttpRequestExecutor实际发出的请求Content-Type为multipart/form-data; charset=ISO-8859-1

自己写代码测试去掉httpPost.setHeader("Content-Type", ContentType.MULTIPART_FORM_DATA.toString());就可以请求成功

模块版本情况

  • WxJava 模块名:weixin-java-mp
  • WxJava 版本号:4.6.0

详细描述

Java异常截图
image

tomcat内部的代码
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions