I am attempting to make an ajax call with formData that includes a list of image files and some strings. However, the call is not successful and I am receiving error 415.
Here is the code:
var file = picChooser.files[0];
var jobExecutionImagesContext = new FormData();
jobExecutionImagesContext.append('file', [file, file]);
jobExecutionImagesContext.append('apptId', '123456789rt78');
jobExecutionImagesContext.append('keyPrefix','images/start');
var request = new XMLHttpRequest();
request.open('POST', "/example/images", true);
request.addEventListener('error', function(response) {console.log("failed ajax call: {}", response); }, false);
request.addEventListener('load', function(response) {console.log("succeeded ajax call: {}", response);}, false);
request.addEventListener('abort', function(response) {console.log("failed ajax call: {}", response); }, false);
request.send(jobExecutionImagesContext);
Java controller code:
@RequestMapping(value = {"/example/images"}, method = RequestMethod.POST)
public @ResponseBody String capturePhotos(final HttpServletRequest request,final HttpServletResponse response) {