ram
ram

Reputation: 2343

how postman REST Client raw json data is sent to server in POST, PUT calls?

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

Answers (5)

Use a double quote for variable and separate it with comma.

example :

{ "id" :"1", "name":"xyz" }

Upvotes: 2

Deepu
Deepu

Reputation: 608

In addition to the below comments, make sure the formatting is right as well.

{
	"param1" : "value1",
	"param2": "value2"
}

Upvotes: 1

Ema.H
Ema.H

Reputation: 2878

In the header option of the request, add Content-Type:application/json
header content-type postman json

and in the body, select Raw format and put your json params like {'guid':'61791957-81A3-4264-8F32-49BCFB4544D8'}

body postman json

I've found the solution on http://www.iminfo.in/post/post-json-postman-rest-client-chrome

Upvotes: 24

Aravind
Aravind

Reputation: 492

Your Request body should be like below when you use raw:

{"param1":"value1","param2":"value2","param3":"value3","param4":"value4"}

Upvotes: 13

Abhinav
Abhinav

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

Related Questions