Spring/RestTemplate - PUT entity to server Spring/RestTemplate - PUT entity to server json json

Spring/RestTemplate - PUT entity to server


You could try something like :

    final String url = String.format("%s/api/shop/{id}", Global.webserviceUrl);    RestTemplate restTemplate = new RestTemplate();    restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());    HttpHeaders headers = new HttpHeaders();    headers.set("X-TP-DeviceID", Global.deviceID);    Shop shop= new Shop();    Map<String, String> param = new HashMap<String, String>();    param.put("id","10")    HttpEntity<Shop> requestEntity = new HttpEntity<Shop>(shop, headers);    HttpEntity<Shop[]> response = restTemplate.exchange(url, HttpMethod.PUT, requestEntity, Shop[].class, param);    shops = response.getBody();

the put returns void whereas exchange would get you a response, the best place to check would be documentation https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html