'Content type 'application/octet-stream' not supported POST 'Mono<FilePart> JAVA
I'm making a POST request to this endpoint
@PostMapping(value = "attachments",consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
public ResponseEntity<Mono<AttachmentResponse>> upload(@RequestPart("file") Mono<FilePart> file,
@RequestPart("Info") String req,
Authentication authentication) {
the request I'm making is this
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add(AUTHORIZATION, tokenRetornado);
MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
multiValueMap.add("Content-Type", "multipart/form-data");
headers.addAll(multiValueMap);
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.add("attachment", blob);
body.add("attachmentInfo", getAttachmentInfo("customer"));
HttpEntity<MultiValueMap<String, Object>> requestEntity =
new HttpEntity<>(new LinkedMultiValueMap<>(), headers);
requestEntity.getBody().addAll(body);
webClient.post()
.uri("http://localhost:8082/receiver/attachments")
.contentType(MediaType.MULTIPART_FORM_DATA)
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromMultipartData(body))
.retrieve()
.bodyToMono(AttachmentResponse.class)
.block();
after making the request I get the error 415 Unsupported Media Type from POST http://localhost:8082/receiver/attachments
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
