I've been using Postman Chrome extension to test out my API and would like to send an Hashmap via post. Is there a way to send something map as a parameter in Postman?
HashMap inputHM = new HashMap();
inputHM.put("MVMT", "VL");
inputHM.put("NO", 1);
inputHM.put("FE", "E");
inputHM.put("CT", "20");
inputHM.put("HT", "80");
inputHM.put("TYPE", "GP");
inputHM.put("OPR_CD", "MAEU");
inputHM.put("LOCATION", "BERT");
inputHM.put("TMNL", "1");
inputHM.put("INCL", "");
inputHM.put("ID", 1);
My Controller is as follows
@RequestMapping(value = "/getBest", method = RequestMethod.POST)
public @ResponseBody
JsonResponse getBest(@RequestBody HashMap hm) {
JsonResponse json = new JsonResponse();
json.setSuccessData(rdtRequestService.getBest(hm));
return json;
}
When you send the request through POSTMAN, select the type as POST, then select the "raw" option and then just send JSON in the "body" with the values you want to put in your HashMap. Remember to select "application/json". Jackson will transform the JSON into a HashMap for you.
An example fragment from your code would be:
{
"NO": 1,
"FE": "E",
"CT": "20"
}
Jackson will do the rest for you, I mean, mapping that JSON to your HashMap.
Please use the following payload in the POSTMAN for a POST method. Please take a look at this post.
{
"LOCATION": "BERT",
"TMNL": "1",
"NO": 1,
"CT": "20",
"OPR_CD": "MAEU",
"MVMT": "VL",
"ID": 1,
"HT": "80",
"INCL": "",
"TYPE": "GP",
"FE": "E"
}
You can pass a map with postman like this,
attribute: {
"key": "value",
"key2": "value2"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With