Hello All,
I have been developing a RESTful API for my application. In that, I am facing an issue when using the multipart/form-data as a enctype in the form to upload a file. Let me explain this in more detail.
I am using JBoss6 as a application server. Initially there was no requirement to attach a file in the form. So i dint specify the enctype in the form. When i submit my form, the expected REST call was made and i got the needed results. I used the following specification in the REST method which was to be called.
@Path("process")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response processDocument(@FormParam("payload") String payload) throws Exception {
// Method
}
Now i need to attach a file with my data when submitting the form. So i added the file element to upload the file. Also i did modified the form enctype as "multipart/form-data". The changes were also made in the REST method as follows,
@Path("process")
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response processDocument(
@FormDataParam("payload") String payload,
@FormDataParam("upfile") File file,
@FormDataParam("desc") String description) throws Exception {
// Method
}
When i submit my form Im getting the following error in the JSF page.
HTTP Status 401 - Account parameter: accountUserId not found in request by: rport
The accountUserId is a hidden field used in the form.
Can anyone tell me what i missed in the above?
Thanks
Ram