I want to send a form parameter from Chrome Advanced REST Client
, however, it comes as null
. This my resource class
IKeywordResource.java
@Path("")
public interface IKeywordResource {
@POST
@Path("/upload")
@Consumes("multipart/form-data")
public List<Keyword> uploadKeywords(MultipartFormDataInput uploadFile,
@FormParam("list_format") String listFormat) throws IOException;
}
KeywordResource
public class KeywordResource implements IKeywordResource {
@Inject
public KeywordService keywordService;
@Override
public List<Keyword> uploadKeywords(MultipartFormDataInput uploadFile,
@FormParam("list_format") String listFormat) throws IOException {
return keywordService.upload(uploadFile, listFormat);
}
}
And this is how I send the POST request and define the form parameter.
However, as I said list_format comes as null that I dont know why. I will appreciate for any kind of help
You are trying to map the request payload twice. You can either map all parameters to a MultipartFormDataInput
object and retrieve your parameter with uploadFile.getFormDataMap().get("list_format");
or you map each parameter with @FormParam
.