hey channel. I’ve been trying to implement a POST ...
# spring
a
hey channel. I’ve been trying to implement a POST with a ByteArray using this:
<http://requestBuilder.POST|requestBuilder.POST>(HttpRequest.BodyPublishers.ofByteArray(payload.httpBody.toByteArray()))
but in the controller I get: Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘application/octet-stream;charset=UTF-8’ not supported] My Controller:
@RestController
@CrossOrigin
@RequestMapping(path = "/")
public class IngestionMockerController {
@PostMapping(value = "/")
public ResponseEntity<String> post(
@RequestBody Byte[] body) {
System.out.println("HttpRequestIngestionRequest = " + Arrays.stream(body).toArray());
return new ResponseEntity<>(HttpStatus.CREATED);
}
}
Please, could someone share an example of HTTP Client posting a ByteArray to a POST endpoint (@RequestBody Byte[] body)?
solved 1
a
Why are you not using a multipart (file) upload?
👍 1
a
Because there is no file to read. Actually, this byte array is a property of a protobuf topic message
hey Channel. The issue was solved with the change in the method declaratiion:
Copy code
public ResponseEntity<String> post(HttpEntity<byte[]> requestEntity)
Thank you for your question @ashmelev
130 Views