vendredi 28 décembre 2018

how i can pass parameters in restTemplate to controller's put method

i have a problem with passing parameters .. I have names in my income app and i want to update them by passing a parameters of new names from my rest app . this is my code :

String url = "http://localhost:8084/rest/api/income/UpdateName/{oldName}/{newName}"; // the Url of the rest


    Map<String, String> params = new HashMap<>();
    params.put("oldName", oldName);
    params.put("newName", newName);
    Income income = new Income();

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.put(url, income, params);
    System.out.println(params);
}    

the code not work ? what i can doing ?

this is the put method in the controller :

@CrossOrigin
@GetMapping("/UpdateName/{oldName}/{clientName}") // view all incomes ..
public GeneralResponse viewAllIncome(@PathVariable("oldName") String oldName,@PathVariable("clientName") String clientName) {

    return new GeneralResponse(incomeServiceTemplate.updateClientName(oldName,clientName));

}    




Aucun commentaire:

Enregistrer un commentaire