I want to create API call by passing string value but without returning output.
Inside API method, only updating the value to database.
How to create API @postmapping(value = "endpoint") in this case
I want to create API call by passing string value but without returning output.
Inside API method, only updating the value to database.
How to create API @postmapping(value = "endpoint") in this case
Why do you not want to return anything? You should return at least true to notify the caller that the transaction was successful.
@PostMapping("/endpoint") public boolean updateSomeData(String value) { boolean result = someService.updateSomething(value); return result; } If you still do not want to return anything, you can simply change return type of the method to void as follows
@PostMapping("/endpoint") public void updateSomeData(String value) { someService.updateSomething(value); } Object because I don't know about your input.String value. You can use or emit @RequestParamIf you want to pass string as pathvariable like,
http://your_host:your_port/your_projectName/endpoint/string_value
you can use below code
@PostMapping(value="/endpoint/{string_value}") public void update(@PathVariable("string_value") String string_value){ //update operation }
If you want to pass string as requestvariable like,
http://your_host:your_port/your_projectName/endpoint?string_value=somevalue
you can use below code
@PostMapping(value="/endpoint") public void update(@RequestParam("string_value") String string_value){ //update operation }