How to make post request with params and body in P

2019-04-07 06:23发布

问题:

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

  2. 'raw' section

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

回答1:

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. ?to=random@email.com&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.

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.



标签: postman