I want send path variable in post mapping, in postman software.I select post mapping body and then how to do? I checked with @RequestParam vs @PathVariable example,all answers for get method, But I need answer for post method.
@RestController
@RequestMapping("api/v1/customers")
public class CustomerController {
@PostMapping("/{code}")
public String postRequest(@PathVariable String code,@RequestBody CustomerDTO dto){
System.out.println(dto);
System.out.println(code);
return "Something";
}
}
A path parameter can be added in to URI as “:<param name>”. We can have multiple path params in a URI. Whatever value you pass for id in Path variables, it will replace in URI. You can also use environment or global variable to pass value to path variables.
@PathVariable can be used in any type of request method (GET, POST, DELETE, etc).
the easy way to put a path variable in Postman is your case is "/:code"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With