简体   繁体   English

如何使用邮递员休息客户端发送对象以调用REST服务,以便它将使用适当的方法参数命中以下给定的方法?

[英]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.

相关问题 如何使用邮递员休息客户端发送对象以调用REST服务 - how to send object using postman rest client to call REST service 如何使用邮递员休息客户端将邮递请求发送到以下邮递方法 - How to send post request to the below post method using postman rest client rest api - 如何在rest api调用中发送邮递员的身体参数 - rest api - how to send body parameters of postman in rest api call 调试不适用于其他方法使用邮递员其他客户端的PUT - debug not working for rest method PUT using postman rest client 如何使用 Post 方法测试在 Rest 服务上获取参数 - How to test getting parameters on the Rest service using the Post method 如何捕获其余api控制器上的文件以及使用Postman发送它的方法 - how to catch a file on the rest api controller and what method to send it with Postman 如何在url中为逗号分隔参数传递休息服务的get方法 - How to pass comma separated parameters in a url for the get method of rest service 对象作为Apache CXF REST服务方法中的参数 - Objects as parameters in Apache CXF REST service method 如何从我的休息服务发送一个json对象,以便我可以在客户端javascript解析 - How do I send a json object from my rest service so I can parse in out on the client side javascript 使用 spring Web 客户端命中 https Z65E8800B5C6800AAD896F888B2A 服务 - Using spring Web Client hit https rest service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM