Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make post request with params and body in Postman

Tags:

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
like image 743
Bartek Avatar asked Apr 05 '18 14:04

Bartek


People also ask

How do you pass a parameter in Postman post method?

Right-click selected text, and choose EncodeURIComponent to manually encode a parameter value. To send a path parameter, enter the parameter name into the URL field, after a colon, for example :id . When you enter a path parameter, Postman will populate it in the Params tab, where you can also edit it.

How do you pass multiple parameters in Postman POST request?

Enter the same URL in the Postman text field; you will get the multiple parameters in the Params tab. Even you can write each of the parameters and send a request with multiple parameters.

How do you send data in the body of POST request?

To send data using the HTTP POST method, you must include the data in the body of the HTTP POST message and specify the MIME type of the data with a Content-Type header. Below is an example of an HTTP POST request to send JSON data to the server. The size and data type for HTTP POST requests is not limited.


1 Answers

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

like image 194
Danny Dainton Avatar answered Oct 12 '22 23:10

Danny Dainton