简体   繁体   English

如何通过 url 和 Z65E8800B5C6800AAD8800B5C6800AAD8800B5C6800AAD896F888B2A62AFCZ 的主体发送请求主体的 json 参数之一为@FCBmapping80AFD3511Z5

[英]How to send one of the json parameter of a request body through url and rest through body of postman for @Postmapping

I have a class:我有一个 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? While doing @Postmapping can we send mssd in the url and rest of the data in the json body in the postman combined?

If possible then what will be written in controller class as @RequestBody in the controller will expect whole data and definitely considering @NotEmpty.如果可能,那么将在 controller class 中作为@RequestBody 写入 controller 中的内容将期望完整数据,并且肯定会考虑@NotEmpty。

Is there any solution available?有没有可用的解决方案?

You can send mssd as PathVariable or RequestParam and rest of the parameter as ReqeustBody as below.您可以将mssd作为PathVariableRequestParam以及参数的 rest 作为ReqeustBody ,如下所示。

@PostMapping(value = "/{id}")
    public String samplePost(@PathVariable("mssd") String mssd, @RequestBody SubMdlChild payload){
       return <your-service-call>;
    }

UPDATE: In the RequestBody , I have taken a sample class name SubMdlChild which will not contain the mssd as per your requirement.更新:RequestBody中,我取了一个示例 class 名称SubMdlChild根据您的要求不包含mssd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 "如何使用 REST Assured 在正文中将请求作为 Json 数组发送以进行 Post" - How to send Request as Json Array in body for Post using REST Assured rest api - 如何在rest api调用中发送邮递员的身体参数 - rest api - how to send body parameters of postman in rest api call 如何放心地在请求中发送复杂的正文? - How to send complex body in the request with rest assured? 如何形成 http 请求主体的 protobuf 资源部分并通过 dhc 客户端或 postman 测试它以获得宁静的服务 - How to form protobuf resource part of http request body and test it through dhc client or postman for restful services 如何使用 JSON 主体在 java 中发送发布请求 - How to send post request in java with a JSON body 通过json从请求发送参数 - send parameter from request through json 无法通过邮递员发送尸体 - Cannot send the body in postman 在 Postman 的请求正文中传递多个 JSON 数据并使用 Jersy(JXRS) 进入 Java Rest API - Pass multiple JSON data in Request Body of Postman and Get into Java Rest API using Jersy(JXRS) 如何发送包含多个对象的 Rest 模板请求正文 - How to I send a Rest Template Request Body with multiple objects in it 如何将请求正文中的列表值发送到 Rest Api - How to send List value in Request Body to Rest Api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM