邮递员 "状态"。415,"错误","不支持的媒体类型", "不支持的媒体类型",

问题描述 投票:-1回答:1

我试图创建一个类,在这个类中我可以添加一个客户(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);
    }

}

这是我对邮递员的要求。http://localhost:8080/api/aulas/1/23

结果是这样的:

{
    "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"
}
java webserver postman
1个回答
0
投票

在邮递员的请求头中提到你的内容类型。

Content-Type application/xml
© www.soinside.com 2019 - 2024. All rights reserved.