Skip to content
Advertisement

How to send a multipart file to a service from another service

I have two endpoints api which are /uploadand /redirect

/upload is where I directly upload the file. /redirect is where i receive the file and pass it to upload and get the JSON response from /upload.So below is my code:

JavaScript

The endpoint /upload works pretty much fine.But when i call /redirect it throws an error of

“exception”: “org.springframework.http.converter.HttpMessageNotWritableException”, “message”: “Could not write JSON document: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile[“inputStream”]->java.io.FileInputStream[“fd”]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile[“inputStream”]->java.io.FileInputStream[“fd”])”,

I am not sure why is this occuring.Any help is appreciated.

Advertisement

Answer

This made the trick

JavaScript

So what I did was basically collected the file rewrite it and then conver to a MultiValueMap and send to the service.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement