[英]How to send Request as Json Array in body for Post using REST Assured
[英]How to send one of the json parameter of a request body through url and rest through body of postman for @Postmapping
我有一个 class:
public class SubMdl {
private Integer Id;
@NotEmpty
private String mssd;
private String name;
private String location;
//constructor,getters,setters
}
While doing @Postmapping can we send mssd in the url and rest of the data in the json body in the postman combined?
如果可能,那么将在 controller class 中作为@RequestBody 写入 controller 中的内容将期望完整数据,并且肯定会考虑@NotEmpty。
有没有可用的解决方案?
您可以将mssd
作为PathVariable
或RequestParam
以及参数的 rest 作为ReqeustBody
,如下所示。
@PostMapping(value = "/{id}")
public String samplePost(@PathVariable("mssd") String mssd, @RequestBody SubMdlChild payload){
return <your-service-call>;
}
更新:在RequestBody
中,我取了一个示例 class 名称SubMdlChild
根据您的要求不包含mssd
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.