1

enter image description hereI have this method but I am not able to figure out which parameters should I pass in postman to execute this method. I sent the body in form-data of postman and content-Type is multipart/form-data.

Later I have to send the file as well that's why I am using form-data.

SearchString is coming out be empty in backend code.

@RequestMapping(value = "/calendar", method = RequestMethod.POST)
protected FareCalendarResponse getCalendar(
        @RequestParam(value = "searchString", required = false) String searchString, HttpServletRequest httpRequest)
        throws Exception {
    CalendarRequest fareRequest = new CalenderRequest(searchString);
    return FareCalendarHandler.builder().httpRequest(httpRequest).request(fareRequest).build().getResponse();
}
Logan
  • 101
  • 1
  • 2
  • 12

2 Answers2

2

I think this link SO Link answers your question. Also, Because its a request Param, that will come as a query param / form data i think from javadocs RequestParam

your postman should look like :

enter image description here

And if you wish to upload file: enter image description here

Raveesh Sharma
  • 1,486
  • 5
  • 21
  • 38
0

I think it must be public
the content-type can be anything, try application/json
You can use postman to POST to http://host:port/calendar?searchString=searchString

Viet Hoang
  • 124
  • 1
  • 4