I am using postman packaged app to send a post request.
I want to request the following controller.
How to send a post requestbody using postman object(with values) and a list using the raw format?
@RequestMapping(value = "register", method = RequestMethod.POST) @ResponseBody public ResponseMessage save(@RequestBody Freelancer freelancer, @RequestBody List<Integer> skills) {
I have tried like this :
{ "address": "colombo", "username": "hesh", "password": "123", "registetedDate": "2015-4-3", "firstname": "hesh", "contactNo": "07762", "accountNo": "16161", "lastName": "jay" } { "array[0]" :1436517454492, "array[1]" :1436517476993 }
In Postman, change the method next to the URL to 'POST', and under the 'Body' tab choose the 'raw' radio button and then 'JSON (application/json)' from the drop down. You can now type in the JSON you want to send along with the POST request. If this is successful, you should see the new data in your 'db. json' file.
Make sure that you have made the content-type
as application/json
in header request and Post from body under the raw tab.
{ "address": "colombo", "username": "hesh", "password": "123", "registetedDate": "2015-4-3", "firstname": "hesh", "contactNo": "07762", "accountNo": "16161", "lastName": "jay", "arrayObjectName" : [{ "Id" : 1, "Name": "ABC" }, { "Id" : 2, "Name" : "XYZ" }], "intArrayName" : [111,222,333], "stringArrayName" : ["a","b","c"] }
I also had a similar question, sharing the below example if it helps.
My Controller:
@RequestMapping(value = {"/batchDeleteIndex"}, method = RequestMethod.POST) @ResponseBody public BaseResponse batchDeleteIndex(@RequestBody List<String> datasetQnames)
Postman: Set the Body type to raw and add header Content-Type: application/json
["aaa","bbb","ccc"]
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