[英]how to send object using postman rest client to call REST service so that it will hit the below given method with proper method parameters?
I am tring to call a rest post method from postman. 我正想从邮递员那里调用休息发布方法。 But I am not able to properly set the input parameters for method from postman.
但是我不能正确地为邮递员设置方法的输入参数。
NB : Please dont mark it as duplicate as this dosent have an existing answer in Stackoverflow. 注意:请不要将其标记为重复项,因为此对象在Stackoverflow中已有答案。
Below the rest API code: 在其余API代码下方:
@RequestMapping(value = "/city/village/home", method = RequestMethod.POST)
@ResponseBody
public String updateHome(@ModelAttribute final HomeAddress homeAddress,
final HttpServletRequest request) {
//// some code /////
}
This is the HomeAddress class
public class HomeAddress{
public String name;
public int id;
public List<String> membersName;
getters.....
setters....
}
Please tell me how to send the request from Postman ? 请告诉我如何发送来自邮递员的请求?
If you are using Spring by default your application will be running on localhost:8080
-> then you can use your value /city/village/home
-> localhost:8080/city/village/home
. 如果默认情况下使用Spring,则您的应用程序将在
localhost:8080
>上运行,则可以使用/city/village/home
> localhost:8080/city/village/home
。 You can take a look for example for Spring Boot Controller - https://adityasridhar.com/posts/how-to-create-simple-rest-apis-with-springboot 您可以看一下Spring Boot Controller的示例-https: //adityasridhar.com/posts/how-to-create-simple-rest-apis-with-springboot
I'm not sure did you use @Controller
annotation on the class and so on... You can see how to use Postman here-> https://adityasridhar.com/posts/how-to-create-simple-rest-apis-with-springboot 我不确定您是否在类上使用
@Controller
注释,等等...您可以在此处查看如何使用邮递员-> https://adityasridhar.com/posts/how-to-create-simple-rest-带有springboot的api
You should use Json Format - you can validate it here : https://jsonformatter.curiousconcept.com/ 您应该使用Json格式-您可以在这里进行验证: https : //jsonformatter.curiousconcept.com/
{
"name": "NAme",
"id": 5,
"membersName": [
"firstName",
"secondName"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.