Java Postman multipart/form-data 错误:缺少起始边界
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33174296/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postman multipart/form-data error: Missing start boundary
提问by Anton Belev
I'm trying to hit my server's endpoint with a multipart/form-data
request sent from Postman. I'm getting a 400 Bad Requestand the cause is:
我正在尝试使用multipart/form-data
Postman 发送的请求访问我的服务器的端点。我收到一个400 Bad Request,原因是:
org.jvnet.mimepull.MIMEParsingException: Missing start boundary.
How can I set the start boundary and how do I know what it should be?
我如何设置起始边界,我怎么知道它应该是什么?
采纳答案by Anton Belev
https://github.com/postmanlabs/postman-app-support/issues/191Following that thread here seems that setting the request header to Content-Type multipart/form-data I'm overriding the value set by Postman.
https://github.com/postmanlabs/postman-app-support/issues/191在此线程之后,似乎将请求标头设置为 Content-Type multipart/form-data 我正在覆盖 Postman 设置的值。
There is no need to add a content-type header manually. You are overriding the value set by Postman. Just select form-data in POST request and send your request to see if it works.
无需手动添加内容类型标头。您正在覆盖 Postman 设置的值。只需在 POST 请求中选择 form-data 并发送您的请求以查看它是否有效。
Removing the header allowed me to hit my endpoint.
删除标题使我能够击中我的端点。
回答by realPK
回答by Gopi Kancharla
As a work around try this:
作为解决方法试试这个:
spring: jersey: application-path: /rest # Path that serves as the base URI for the application. Overrides the value of "@ApplicationPath" if specified. filter.order: 0 # Jersey filter chain order. type: servlet # Can be either "servlet" or "filter". init.*:
spring: jersey: application-path: /rest # 用作应用程序基本 URI 的路径。如果指定,则覆盖“@ApplicationPath”的值。filter.order: 0 # Jersey 过滤器链顺序。type: servlet # 可以是“servlet”或“filter”。在里面。*:
type servlet worked fine, where as filter is throwing the Start Boundary error.
类型 servlet 工作正常,因为过滤器抛出了起始边界错误。