Jersey includes dynamic content type

A similar question can be found here: Support for Multipart and Application Url Encoded coding options in Jersey

I have an API endpoint (in Jersey) that can accept a POST request. Content types are either: form-urlencoded or multipart. Two types of requests arrive on the same path. How to enable this?

For the urlencoded request, I want to get the argument:

@FormParam("recipient") String recipient 

For a multidisciplinary request, I want to get:

 @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail 

Thanks!

+1
source share
1 answer

I think Jersey allows a single method for each unique pair of @Path and @VERB , which means you will need to either have one of these things using the other verb (POST and PUT), or you need two different paths. Before you just go and make one POST and another PUT, make sure that you understand how to use verbs in REST correctly .

+1
source

Source: https://habr.com/ru/post/908875/


All Articles