I need to have a method that does not regard/parse the content of request message, just ... pass it along as input parameter to the @PostMapping method. Is it possible? Because defining parameters like:
@RequestBody byte[] data
or
@RequestBody String text
tell the framework that it suppose to get some xml/json. and I want it to receive plain text + utf-8 encoding.
Some code to clarify:
@RestController
@RequestMapping(path="/abc", method = RequestMethod.POST)
public class NlpController {
@PostMapping(path="/def", consumes="text/plain; charset: UTF-8", produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> processText(@RequestBody String text)
{
...
return ResponseEntity.ok().body(object);
}
}
Trying also:
@RestController
@RequestMapping(path="/abc", method = RequestMethod.POST)
public class NlpController {
@PostMapping(path="/nlp", consumes=MediaType.APPLICATION_JSON_UTF8_VALUE, produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> process(HttpServletRequest request)
{
....
return ResponseEntity.ok().body(article);
}
}
But I get 406 response...
using curl:
curl -v -s -X POST -H "Content-Type:" -H "Content-Type: application/json; charset: utf-8" --data-binary @article.txt localhost:8080/abc/def/