title: How to return CREATED status (201 HTTP) in ResponseEntity
body: <p>There is a <code>Spring-MVC</code> application. In controllers, when returning the results of methods, I return via <code>ResponseEntity&lt;&gt;</code>. On success, I return (<code>200</code> statutes) the <code>OK</code>-method. But when creating something, I would like to return the <code>CREATED</code>-method (<code>201</code> status). I just can’t understand what kind of <code>URL</code> to ask in parentheses when calling through <code>CREATED</code>. How can this be implemented?</p>
  
  <p>Now I have such an implementation:</p>
  
  <pre class="lang-java prettyprint-override"><code>@PostMapping("/create/dish")
      ResponseEntity&lt;Dish&gt; createDish(@Valid @RequestBody DishDTO dishDTO) {
  
          return ResponseEntity.ok(cookService.createDish(dishDTO.getDishName(), dishDTO.getAboutDish(), dishDTO.getDishType(),
                  dishDTO.getCookingTime(), dishDTO.getWeight(),
                  dishDTO.getDishCost(), dishDTO.getCooksId()));
      }
  </code></pre>
  
  <p>I want to remake it like this to make it work(now it not work):</p>
  
  <pre class="lang-java prettyprint-override"><code>@PostMapping("/create/dish")
      ResponseEntity&lt;Dish&gt; createDish(@Valid @RequestBody DishDTO dishDTO) {
  
          return ResponseEntity.created(cookService.createDish(dishDTO.getDishName(), dishDTO.getAboutDish(), dishDTO.getDishType(),
                  dishDTO.getCookingTime(), dishDTO.getWeight(),
                  dishDTO.getDishCost(), dishDTO.getCooksId()));
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ULn0L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ULn0L.png" alt="enter image description here"></a></p>
  
  <p>P.S. I don’t have a frontend at all. All through Swagger or PostMan.</p>