0
@RequestMapping(value="/postdata", method= RequestMethod.POST, consumes="application/json")
public String postdata(@RequestBody String test, @RequestBody String data) {
        logger.info("password reset Request " + requestbody.get("test"));
        logger.info("password reset Request " + data);
        return "Hello";
}

Resolved [org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public java.lang.String mail.controller.EmailNotifictaionController.postdata(java.lang.String,java.lang.String)]

My Input in the SOAPUI is { "test":"my", "data":"god" }

Uma
  • 1
  • 1

1 Answers1

2

You are using two @RequestBody which is not the correct way as one request can only have one request body.

You can either combine both the request bodies into single request body or you can build a wrapper class having both the test and data variables like:

public class Body {
    public String test;
    public String data;
    // You can also keep them private and have getters/setters.
}

and use this class in the API method argument

@RequestMapping(value="/postdata", method= RequestMethod.POST, consumes="application/json")
public String postdata(@RequestBody Body body) {
        logger.info("password reset Request " + body.test);
        logger.info("password reset Request " + body.data);
        return "Hello";
}

You can try this way, it should work.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Amrit Singh
  • 143
  • 1
  • 7
  • Thanks a lot!! I was so far trying with multiple @RequestBody, now using a Single wrapper class – Uma Jul 01 '21 at 14:41