0

This is my request URL - https://api100.abc.com:9443/aa/bb/rest/getList

I am hitting this URL using POSTMAN REST Client. In header tab I have added "{"Content-Type":"application/json"}" and in Body tab in raw section I have added my JSON object -

{
"tokenID": "10503010",
"resultType1": 3,
"resultType2": 4,
"scCode": 1
}

I have added one pojo class BankParam and in that class I have added tokenID, resultType1, resultType2, scCode as variables.

My REST service code is

@RequestMapping(value="/getList", method=RequestMethod.POST, produces={MediaType.APPLICATION_JSON_VALUE}, consumes={MediaType.APPLICATION_JSON_VALUE})
@ApiOperation(value="Retrieves list of banks")
public List<Bank> getBankList (BankParam bankParam){

    System.out.println(bankParam.getTokenID());

}

In the above code I am getting null value as bankParam object is empty. I want to pass this object using POSTMAN client. Please help me out. Thanks !

2 Answers 2

2

You need to add RequestBody annotation just before the parameter.

@PostMapping(value="/getList")
@ApiOperation(value="Retrieves list of banks")
public List<Bank> getBankList (@RequestBody BankParam bankParam){
    System.out.println(bankParam.getTokenID());
}
Sign up to request clarification or add additional context in comments.

Comments

0

Update your REST code as below:

@RequestMapping(value="/getList", method=RequestMethod.POST, produces={MediaType.APPLICATION_JSON_VALUE}, consumes={MediaType.APPLICATION_JSON_VALUE})
@ApiOperation(value="Retrieves list of banks")
public List<Bank> getBankList (@RequestBody BankParam bankParam){

    System.out.println(bankParam.getTokenID());

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.