Question

A similar question is here: Supporting both Multipart and Application Url Encoded parameters in Jersey

I have an API endpoint (in Jersey) that can accepts POST request. The content types are either: form-urlencoded, or multipart. The two types of request arrive at the same path. How do I switch on that?

For the urlencoded request, I want to get argument:

@FormParam("recipient") String recipient

For multipart request, I want to get:

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

Thanks!

Was it helpful?

Solution

I think that Jersey only allows a single method for each unique @Path & @VERB pair, meaning that you'll either need to have one of those things use a different verb (POST and PUT) or you need two different paths. Before you just go and make one POST and the other PUT, make sure you understand how to properly use verbs in REST.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top