简体   繁体   English

无法使用邮递员发送发帖请求

[英]can not send a post request using postman


I am trying to sand post request using postman. 我正在尝试使用邮递员发送请求。 for some reason i am getting 400 Bad Request - Required request body is missing. 由于某种原因,我收到400错误的请求-缺少所需的请求正文。 My controller is in spring boot environment. 我的控制器处于春季启动环境中。
My controller: 我的控制器:

    @RestController
    public class HagarController {

      @PostMapping(value = "/hagar")
      @ResponseStatus(HttpStatus.OK)
      public void hagar(@RequestBody String name, @RequestBody String id) 
      throws Exception{
          System.out.println("my name is: " + name +" id: " + id);
      }
    }

The postman request img 邮递员要求img

Thanks!! 谢谢!!

This is how I do it, I hope it will help you: 这是我的操作方式,希望对您有所帮助:

@RestController
public class HagarController {

  @ResponseMapping(value = "/add", method = RequestMethod.POST)
  public void hagar(@RequestBody String name, @RequestBody String id) 
      System.out.println("my name is: " + name +" id: " + id);
}

and in postman you probably added in Headers: see image : enter image description here 在邮递员中,您可能已在标题中添加了: 查看图片在此处输入图片说明

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

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