简体   繁体   English

无法通过邮递员发送尸体

[英]Cannot send the body in postman

I have the following code:我有以下代码:

@PostMapping()
    public ResponseEntity<Object> postAccounts(
            @RequestHeader(value = "client-id", required = true) String clientId,
            @RequestHeader(value = "X-client-Global-Id", required = false) String clientGlobalID,
            @RequestHeader(value = "Authorization", required = true) String authorization,
            @Valid @RequestBody(required = true) String inputContract, @RequestBody(required = true)String nameInput, @RequestBody(required = true) Boolean state) {

        return new ResponseEntity<>(inputContract, HttpStatus.OK);
    }


When call this method by postman give me an error.当邮递员调用此方法时给我一个错误。

trace": "org.springframework.http.converter.HttpMessageNotReadableException: I/O error while reading input message; nested exception is java.io.IOException: Stream closed\r\n\tat org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:217)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:158)\r\n\tat 

You only can send an one RequestBody, if you want send more than one properties in the body.如果要在正文中发送多个属性,则只能发送一个 RequestBody。 You must create an object你必须创建一个对象

@PostMapping()
    public ResponseEntity<Object> postAccounts(
           //Other Headers...,
            @Valid @RequestBody(required = true) ObjectWithAllFields) {

        return new ResponseEntity<>(ObjectWithAllFields, HttpStatus.OK);
    }


EDIT 1编辑 1

And pls send your error trace.并请发送您的错误跟踪。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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