Bartek
Bartek

Reputation: 2219

How to make post request with params and body in Postman

I have endpoint which takes few parameters and body as input, and I want to test it in Postman. But, when I input data into 'form-data' section in Postman backend throws error that I am missing body. If I try input data into 'raw' (Text) it complains that I forgot about parameters. How can I combine params and body?

EDIT:

  1. 'form-data' section enter image description here

  2. 'raw' section enter image description here

Parameters for that endpoint are following:

@RequestParam("to") String to,
@RequestParam("subject") String subject,
@RequestBody String content,
@RequestParam("isMultipart") Boolean isMultipart,
@RequestParam("isHtml") Boolean isHtml

Upvotes: 20

Views: 126660

Answers (1)

Danny Dainton
Danny Dainton

Reputation: 25921

For the request params you would add them to the end of the URL rather than in the request body, like you have done in the image. [email protected]&subject=Testing mailing feature&isMultipart=false&isHTML=true

This can be seen in the Postman UI when you select the Params button, this can be found next to the Send button.

Params

I'm unsure about the string that you need in the request body and in what format the endpoint requires this data.

If it's in a JSON format you could add {"content": "Some new content"} to the raw body and select JSON (application/json) from the dropdown, this will also set the correct request header.

Edit:

The UI has changed slightly since this answer was given. The Paramstab is now placed in a less confusing place.

New Location

Upvotes: 31

Related Questions