Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send PathVariable @PostMapping in postman

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";
    }
}
like image 942
Dumidu Udayanga Avatar asked Nov 14 '18 02:11

Dumidu Udayanga


People also ask

How do you send two path variables in Postman?

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.

Can we have PATH variable in post request?

@PathVariable can be used in any type of request method (GET, POST, DELETE, etc).


1 Answers

the easy way to put a path variable in Postman is your case is "/:code"

check link to see how to add path variables in Postman

like image 131
szyjek Avatar answered Sep 22 '22 14:09

szyjek