Send Pathvariable @Postmapping in Postman

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";
    }
}
7

3 Answers

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

3

select post -> add the url -> select body -> choose raw -> select JSON(application/json) -> add your json data -> click send

1

You can refer official documentation :

Please go to charpter URL .

Some API endpoints use path variables. You can work with those in Postman. Below is an example of a URL with a path variable:

To edit the path variable, click on Params to see it already entered as the key. Update the value as needed. For example, :entity can be “user” in this specific case. Postman also gives you suggestions to autocomplete the URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.