How to POST avro/json data to Spring boot rest controller

Viewed 946

I have a rest controller method like this -

@RequestMapping(method = RequestMethod.POST, value = "/avdata",
                consumes = {"application/json", "avro/binary", "avro/json"})
                ResponseEntity<?> handleAvroData(@RequestHeader Map<String, String> httpHeaders,
                                                 @RequestBody Object input) {

This method does not have to process any avro data. It just has to push it on to a Kafka topic after doing some logging.

When I do a curl request

curl --data '{"name":"test"}' -X POST -H 'Content-Type:avro/json' http://localhost:8080/avdata

it gives me the following error

{"timestamp":1509654385753,
 "status":415,
 "error":"Unsupported Media Type",
 "message":"Content type 'avro/json;charset=UTF-8' not supported",
 "path":"/avdata"
}

Is there a way I can post avro data to a spring boot rest controller?

0 Answers
Related