简体   繁体   中英

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.

Below the rest API code:

@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 . You can take a look for example for 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

You should use Json Format - you can validate it here : https://jsonformatter.curiousconcept.com/

{
  "name": "NAme",
  "id": 5,
  "membersName": [
     "firstName",
    "secondName"
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM