postman使用post传入参数,如何在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:

'form-data' section

03U0J.png

'raw' section

Jc0WB.png

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

解决方案

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.

AJXVN.png

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.

vcKyw.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值