Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-3463

Support FormParam with EntityPart

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 6.2.8.Final, 7.0.0.Alpha1
    • 6.2.7.Final
    • jaxrs
    • None
    • Hide

      create a class:

      @Path("widgets4")
      public class WidgetsResource4 {

      @POST
      @Consumes(MediaType.MULTIPART_FORM_DATA)
      public Response postWidget(@FormParam("part1Name") String part1,
      @FormParam("part2Name") InputStream part2,
      @FormParam("part3Name") EntityPart part3)

      { ... }

      }

      Show
      create a class: @Path("widgets4") public class WidgetsResource4 { @POST @Consumes(MediaType.MULTIPART_FORM_DATA) public Response postWidget(@FormParam("part1Name") String part1, @FormParam("part2Name") InputStream part2, @FormParam("part3Name") EntityPart part3) { ... } }
    • 2637017

      According to the spec, it should be possible to declare a parameter like @FormParam("part3Name") EntityPart part3. But when I do, I get a 400 Bad Request. The full response is also not very helpful:

      HTTP/1.1 400 Bad Request
      Access-Control-Allow-Credentials: true
      Access-Control-Allow-Headers: origin, content-type, accept, authorization
      Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD
      Access-Control-Allow-Origin: *
      Connection: keep-alive
      Content-Length: 0
      Date: Sun, 03 Mar 2024 09:28:33 GMT

       

      OTOH, using List<EntityPart> parts and then:

      var part3 = parts.stream().filter(part → "part3Name".equals(part.getName())).findFirst().orElseThrow();
      works just fine.

              jperkins-rhn James Perkins
              ruediger.dohna@codecentric.de Rüdiger zu Dohna (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: