![](/img/trans.png)
[英]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.