I am currently using the Java MicroProfile RestClient and have following problem:
- Backend provides an api to receive binary files
- Backend would be happy to receive a Content-Type header containing the Mime-Type of the binary file
- I am not able to set Content-Type per method parameter
I have following code on client-side:
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import io.smallrye.mutiny.Uni;
@RegisterRestClient
public interface RestClient {
@POST
@Path("/api/path/v1")
Uni<String> createResource(@HeaderParam("Content-Type") String contentType, byte[] body);
}
The @HeaderParam("Content-Type") will always be overwritten with "application/json".
If I set the @Consumes Property the Content-Type would always be the same but I want to set it during the method call. (byte[] could contain image, video, text ...)
Has anyone an idea how I could archive this? May there is a better option instead of using a simple byte[] as body?
Best thanks!