title: HttpClientErrorException: 404 null
body: <p>I try to call the address in the controller using RestTemplate and as a result I want to get OK or NOT FOUND status
  I do so in this controller </p>
  
  <pre><code>@GetMapping(value = "/thanks")
  public ModelAndView confirmAccount(
          @RequestParam String token,
          UriComponentsBuilder uriComponentsBuilder
  ) {
      RestTemplate restTemplate = new RestTemplate();
      HttpEntity&lt;Object&gt; entity = new HttpEntity&lt;&gt;(new HttpHeaders());
  
      UriComponents uriComponents
              = uriComponentsBuilder.path("/register/token/{token}").buildAndExpand(token);
  
      ResponseEntity&lt;Boolean&gt; response = restTemplate
              .exchange(uriComponents.toUri(),
                        HttpMethod.PUT,
                        entity,
                        Boolean.class);
  
      return response.getStatusCode().toString().equals("200")
              ?  new ModelAndView("redirect:/signIn") : new ModelAndView("tokenNotFound");
  }
  </code></pre>
  
  <p>I call this address of the controller.</p>
  
  <pre><code>@RequestMapping(value = "/register/token/{token}", method = RequestMethod.PUT)
  public
  HttpEntity&lt;Boolean&gt; confirmAccount(
          @PathVariable String token
  ) {
      Optional&lt;User&gt; userOptional = userService.findByActivationToken(token);
  
      if(userOptional.isPresent()) {
          User user = userOptional.get();
  
          user.setActivationToken(null);
          user.setEnabled(true);
  
          userService.saveUser(user);
      } else {
          return ResponseEntity.notFound().build();
      }
  
      return ResponseEntity.ok(true);
  }
  </code></pre>
  
  <p>As a result, she throws me out in the console</p>
  
  <pre><code>org.springframework.web.client.HttpClientErrorException: 404 null
  at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:63) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
  at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
  at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
  at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:628) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
  at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:549) ~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
  at com.service.app.controller.RegisterController.confirmAccount(RegisterController.java:40) ~[classes/:na]
  </code></pre>
  
  <p>Why does RestTemplate not want to return the status 404 as a result?
      enter code here</p>