简体   繁体   中英

How can a spring controller deal with application/octet-stream request?

I wrote a spring controller with following methods to deal with a callback http request,

@PostMapping ("/test")
public void notifyTranscodeResult(String paramStr){
   ...
}


@PostMapping ("/test2")
public void notifyTranscodeResult(@RequestBody ParamClass param){
   ...
}

but I get errors: Resolved exception caused by handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/octet-stream' not supported

I can't change the callback http request because they are from other third-party services, how can I change my controller to correctly get the request params?

You need to define consumes attribute.

@PostMapping (path = "/test2", consumes = {MediaType.APPLICATION_OCTET_STREAM_VALUE})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM