I am looking to test my REST resource on dropwizard using CURL command. I am able to upload the file and get the content and file name. But along with the file I want to pass some list of Ids as well.
- How can I pass list of long ids (array of Long data type) to the REST service in the below CURL command?
- Can I pass a json structure additionally in the below command if required along with my file content?
CURL command
curl -F 'file=@/cygdrive/c/TestDocument1.txt' http://localhost:8199/test-app/api/upload-documents/1004/documents
REST service to upload file
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/reconciliation-details/{reconciliationDetailId}/documents")
public Response uploadDocument(@FormDataParam("file") File inventoryDocumentContent,
@FormDataParam("file") FormDataContentDisposition fileDetail,
@FormDataParam("reconciliationIds") List<Long> reconciliationIds) throws Exception {
byte[] documentContent = FileUtils.readFileToByteArray(inventoryDocumentContent);
String documentName = fileDetail.getFileName();
reconDetailsService.uploadDocument(documentName, documentContent, reconciliationIds);
return ResponseHelper.createOkResponse();
}