title: Spring MVC + AngularJS 415 Unsupported Media Type
body: <p>The question is very simple and I know it was answered in many other question but none worked for me. Using Spring MVC and AngularJS I am getting AngularJS 415 Unsupported Media Type ! </p>
  
  <p>I tried setting angular header to application/json<br>
  I tried with <code>@Consumes</code> annotation on Server Side<br>
  I tried with <code>consumes ="application/json"</code><br>
  I tired with <code>consumes ="application/application/json;charset=UTF-8'</code><br>
  I tried with <code>consumes ={"application/json","application/xml"}</code><br>
  I also tried to setup produces   property.</p>
  
  <p>I tried explicitly setting the hear content type on the client to match exactly the one on the server but,  NOTHING WORKED !
  here are related questions that none actually helped ! 
  <a href="https://stackoverflow.com/questions/20950346/angularjs-spring-415-unsupported-media-type">1</a><br>
  <a href="https://stackoverflow.com/questions/20950346/angularjs-spring-415-unsupported-media-type">2</a> 
  <a href="https://stackoverflow.com/questions/23009320/415-unsupported-media-type-with-spring-mvc-and-rest-service">3</a></p>
  
  <p>Here is my Controller </p>
  
  <pre><code>/**
   * Created by adelin.ghanayem@gmail.com
   */
  @Controller
  @RequestMapping(value = "/administration/places")
  public class PlacesController {
  
      private PlacesService service;
  
      @Autowired
      public PlacesController(PlacesService service) {
  
          this.service = service;
  
      }
  
  
      @RequestMapping(method = RequestMethod.POST,consumes = {"application/json;charset=UTF-8"})
      public String newPlace(@RequestBody Place places) {
  
          String id = service.addNewPlace(places);
  
          return "/administration/places/" + id;
  
      }
  
  
      @RequestMapping(value = "/{id}")
      public Place getById(@PathVariable String id) {
  
          return new Place();
  
      }
  
  
  }
  </code></pre>
  
  <p>And my AngularJS controller </p>
  
  <pre><code>function NewPlacesController(scope, http) {
  
  
      scope.place = {};
  
      scope.add = function () {
  
          http.post(URLS.addNewPlace, scope.place,{'Content-Type': 'application/json'}).success(function (value) {
  
              console.log("got it !");
  
          }).error(function (value) {
              console.log("CUR!");
          });
  
      }
  }
  
  NewPlacesController['$inject'] = ['$scope', '$http'];
  </code></pre>