I have the following application details, where I am adding protobuf to an existing spring boot application.
pom.xml dependencies
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.21.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.protobuf-java-format</groupId>
<artifactId>protobuf-java-format</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
Application.java I have added the formatter as given below in Application.java
@Bean
ProtobufHttpMessageConverter protobufHttpMessageConverter() {
return new ProtobufHttpMessageConverter();
}
Spring boot version used: 2.6.9
The below is the API controller
@PostMapping(value = "/reports/process", consumes = "application/x-protobuf")
public ResponseEntity<Boolean> processReports(
@Parameter(description = "Process report data", required = true)
@RequestBody ReportCollection executionReports) {
I have written and generated the .proto
file for Java (above application)
The same .proto file is used in python and python generated the data and posted to the above API using application/x-protobuf
in both the Accept
and Content-Type
headers.
However the Spring boot API that received the payload throws the below exception
Could not resolve parameter [0] in public org.springframework.http.ResponseEntity<java.lang.Boolean> com.*.ReportsApiController.processReports(com.*.ReportCollection): Content type 'application/x-protobuf;charset=UTF-8' not supported
I have been googling for solution and not able to get this fixed, can you please help me