I was getting this error:
HTTP Status 500 - java.lang.IllegalStateException: The @FormParam is
utilized when the content type of the request entity is not
application/x-www-form-urlencoded
My method was:
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("fajl") InputStream uploadedInputStream,
@FormDataParam("fajl") FormDataContentDisposition fileDetail,
@FormParam("param2") String secondParam) { ...
and after replacing @FormParam with @FormDataParam , everything worked out!
:) :) :)
Thank You for posting the solution! I hope my comment will help future
Googlers find this more easily.
On Friday, July 22, 2016 at 4:39:40 AM UTC+2, Joel wrote:
>
> Turns out I needed to use @FormDataParam, not @FormParam as I was using. :(
>
>
> On Thursday, July 21, 2016 at 1:41:41 PM UTC-5, Joel wrote:
>>
>> I'm getting the error when trying to post an uploaded file:
>> The @FormParam is utilized when the content type of the request entity is
>> not application/x-www-form-urlencoded
>>
>> I thought this might be needed, so I added this, with no effect :
>> bootstrap.addBundle(new MultiPartBundle());
>>
>> My server call looks like this:
>>
>> @POST
>> @Path("/upload/{uuid}")
>> @Consumes(MediaType.MULTIPART_FORM_DATA)
>> public Response uploadFile(
>> @NotNull @PathParam("uuid") String uuid,
>> @NotNull @FormParam("title") String title,
>>
>> and the curl test call says its sending form-data:
>> Content-Type: multipart/form-data; boundary=--------------------
>>
>> I don't understand why it thinks application/x-www-form-urlencoded is
>> involved?
>>
>> This call works if instead I user QueryParam's rather than FormParams,
>> but that just seems wrong, but I might just have to go that direction if I
>> can't find a solution.
>>
>> This is on 0.9.3, I'd love to see a working example of file upload
>> w/FormParams. The examples I've found tend not to be current, and seem to
>> match what I have, give or take version changes.
>>
>> Joel
>>
>
--
You received this message because you are subscribed to the Google Groups
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.