Search code examples
jsonspringgetpostmanspring-restcontroller

How to send JSON from postman for a custom VO


What is the format of JSON that I should be sending from Postman to correctly map it to my rest controller.

TfundsVO :
BigDecimal accountNum
String accountName
BigDecimal accountBal



@GetMapping("/")
public ResponseEntity<Object> getFunds(@RequestBody TfundsVO tfundsVO) {
    System.out.println(tfundsVO.getAccountNum());
}

Sample JSON used:

{
    "tfundsVO": [
     {
        "accountName": "Sam"
     } 
  ]
}

When I tried the above JSON from Postman, call goes to the getFunds method, however all the values in TfundsVO are NULL.


Solution

  • Just send the payload without an array

    { "account name": "test" }
    

    And please add an application/json header as a content-type