Discussion:
Exception: The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded
Joel
2016-07-21 18:41:41 UTC
Permalink
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 dropwizard-user+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Joel
2016-07-22 02:39:39 UTC
Permalink
Post by Joel
not application/x-www-form-urlencoded
bootstrap.addBundle(new MultiPartBundle());
@POST
@Path("/upload/{uuid}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@NotNull @PathParam("uuid") String uuid,
@NotNull @FormParam("title") String title,
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 dropwizard-user+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Casper Aleks
2017-02-13 19:22:45 UTC
Permalink
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.
Post by Joel
not application/x-www-form-urlencoded
bootstrap.addBundle(new MultiPartBundle());
@POST
@Path("/upload/{uuid}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@NotNull @PathParam("uuid") String uuid,
@NotNull @FormParam("title") String title,
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 dropwizard-user+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mohammed Chowdhry
2016-10-13 19:05:19 UTC
Permalink
Very helpful! Thanks!
Post by Joel
not application/x-www-form-urlencoded
bootstrap.addBundle(new MultiPartBundle());
@POST
@Path("/upload/{uuid}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@NotNull @PathParam("uuid") String uuid,
@NotNull @FormParam("title") String title,
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 dropwizard-user+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...