[
https://issues.apache.org/jira/browse/CXF-8323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17174014#comment-17174014
]
Andriy Redko commented on CXF-8323:
-----------------------------------
Hi [~arulprakas] ,
Handling form / multipart is a bit tricky with JAX-RS in general. CXF has an
extension to support it in a form of
`org.apache.cxf.jaxrs.ext.multipart.Multipart` annotation, basically the only
change you have to do is to replace `@FormParam` with `@Multipart`, fe:
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
@PUT
@Consumes(value = \{MediaType.MULTIPART_FORM_DATA})
@ApiOperation(value = "Sends a notification")
public boolean sendNotificationPut(
@Multipart(QueryParams.SUBJECT) String subject,
@Multipart(QueryParams.MESSAGE) String message) {
}
You may need to add corresponding @ApiParam annotations to properly document
this semantics, since Swagger does not recognize `@Multipart` out of the box,
it is CXF specific. Thanks.
Best Regards,
Andriy Redko
> CXF along with Spring boot Multipart request fails with 400
> -----------------------------------------------------------
>
> Key: CXF-8323
> URL: https://issues.apache.org/jira/browse/CXF-8323
> Project: CXF
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.1.16
> Reporter: Arul
> Priority: Major
> Fix For: 3.1.16
>
>
> I am using spring boot along with Apache CXF. My REST API definition looks as
> below
>
> @PUT
> @Consumes(value = \{MediaType.MULTIPART_FORM_DATA})
> @ApiOperation(value = "Sends a notification")
> public boolean sendNotificationPut(
> @FormParam(QueryParams.SUBJECT) String subject,
> @FormParam(QueryParams.MESSAGE) String message) {
> }
>
> ---------------------------------------------------------------------------
>
> When we hit via REST client, we are always getting 400.
>
> > PUT /rest/notifications HTTP/1.1
> > Host: localhost:9080
> > User-Agent: insomnia/2020.3.3
> > Content-Type: multipart/form-data; boundary=X-INSOMNIA-BOUNDARY
> > Accept: */*
> > Content-Length: 231
> | --X-INSOMNIA-BOUNDARY
> | Content-Disposition: form-data; name="subject"
> | A new topic has been created
> | --X-INSOMNIA-BOUNDARY
> | Content-Disposition: form-data; name="message"
> | A new topic has been created
> | --X-INSOMNIA-BOUNDARY--
> * We are completely uploaded and fine
> * Mark bundle as not supporting multiuse
> < HTTP/1.1 400
> < Content-Encoding: UTF-8
> < Date: Tue, 04 Aug 2020 05:08:42 GMT
> < Content-Type: text/plain
> < Content-Length: 50
> < Connection: close
--
This message was sent by Atlassian Jira
(v8.3.4#803005)