Reputation: 2343
I'm working on a application to test API calls, in which i'm able to generate URL for paramaters which is declared with annotation @Requestparam and @Pathvariable.
But when using @RequestBody we use raw in post man. I'm not sure how data is sent in raw. I just want to know how to send data in raw to server.
Any help is appreciated. Thanks in Advance.
I'm doing this as AJAX using Jquery.
Upvotes: 16
Views: 78019
Reputation: 141
Use a double quote for variable and separate it with comma.
{ "id" :"1", "name":"xyz" }
Upvotes: 2
Reputation: 608
In addition to the below comments, make sure the formatting is right as well.
{
"param1" : "value1",
"param2": "value2"
}
Upvotes: 1
Reputation: 2878
In the header option of the request, add Content-Type:application/json
and in the body, select Raw format and put your json params like {'guid':'61791957-81A3-4264-8F32-49BCFB4544D8'}
I've found the solution on http://www.iminfo.in/post/post-json-postman-rest-client-chrome
Upvotes: 24
Reputation: 492
Your Request body should be like below when you use raw:
{"param1":"value1","param2":"value2","param3":"value3","param4":"value4"}
Upvotes: 13
Reputation: 39904
You just need to set the 'data' attribute in the $.ajax call as shown here: http://api.jquery.com/jQuery.ajax/.
Upvotes: 1