[英]postman "status": 415, "error": "Unsupported Media Type",
I was trying to creat a class where I could add a client(cliente) to a class(aula)我试图创建一个 class,我可以在其中添加一个客户端(cliente)到一个类(aula)
@RequestMapping(value = "/aulas/{numero}/{numerocliente}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_XML_VALUE, produces = MediaType.APPLICATION_XML_VALUE)
public ResponseEntity<Object> addClienteAula(@PathVariable("numero") int nraula, @PathVariable("numerocliente") int nrclente) {
try {
AulaService.addAlunoAula(nraula, nrclente);
return new ResponseEntity<>(HttpStatus.CREATED);
} catch (Exception e) {
return new ResponseEntity<>(new ErroDTO(e), HttpStatus.CONFLICT);
}
}
here is my request on postman:这是我在 postman 上的请求:
http://localhost:8080/api/aulas/1/23
and this is how it turns out:结果是这样的:
{
"timestamp": "2020-04-25T00:12:02.300+0000",
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type 'text/plain' not supported",
"path": "/api/aulas/1/23"
}
Mention your content type in your postman's request header在邮递员的请求中提及您的内容类型 header
Content-Type application/xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.