For my project requirement, I created an API in JAVA which accepts 2 parameters like below
getSimilarImages(@PathParam("rbcCode") String rbcCode, List<String> fieldNames)
I am new to POSTMAN application.
Could anyone educate me on how do I call this API using POSTMAN.
Below is my controller file code.
@Controller
@Path("/services/AIMLServices")
public class AIMLController {
private static Logger LOG = LogManager.getLogger(AIMLController.class);
@Autowired
AIMLService aimlService;
@POST
@Path("/getSimilarImages/{rbcCode}")
@Produces(MediaType.APPLICATION_JSON)
public String getSimilarImages(@PathParam("rbcCode") String rbcCode, List<String> fieldNames) {
LOG.info("IN getSimilarImages() API");
System.out.println("IN getSimilarImages() API rbcCode=" + rbcCode + " No of fields=" + fieldNames.size());
return aimlService.getSimilarImages(rbcCode, fieldNames).toString();
}
}
I tried with this below setup in POSTMAN,
Doing a post call with the below URL by passing rbcCode
http://localhost:4990/dev/acs/admin/fm/api/services/AIMLServices/getSimilarImages/BELK
And under Body raw type as JSON, I am passing list like below
["a","b","c"]
but it did not work.
I believe you need to add @ResponseBody
on your method and use @RequestBody for your list parameter.
Also as others mentioned, you need to specify your path param in the @Path