title: Sending JSON to server is giving 415 Unsupported Media Type
body: <p>I have the following angular code:</p>
  
  <pre><code>&lt;button ng-click="ctrl.submit(light)"&gt;Switch&lt;/button&gt;
  </code></pre>
  
  <p>and the button click is handled by:</p>
  
  <pre><code>   self.submit = function(light) {
          console.log("==============================");
          console.log("clicked button: ", light);
          console.log("==============================");
  
          $http.post('/ARHomeAutomation/rest/light/state/', light).then(function(response) {
              console.log('headers: ' , response.headers);
              console.log('status: ', response.status);
              console.log('config: ', response.config);
              console.log('data: ', response.data);
              self.state = response.data;
          }, function(errResponse) {
            console.error('Error while updating light state');
          })
          console.log('User clicked submit with: ', light.id );
          console.log('response: ', self.light);
      }
  </code></pre>
  
  <p>On the server side I have the following method that should respond to the request:</p>
  
  <pre><code> @POST
   @Path("/state/")
   @Consumes(MediaType.APPLICATION_JSON)
   @Produces(MediaType.TEXT_HTML)
   public String setStateOfLight(JSONObject aLight) {
      if(aLight == null) {
        return "It's a null";
      } else {
        System.out.println("content: " + aLight);
      }
      JSONObject jsonObject = new JSONObject();
      //Update the state of the light with the given id
      for(Light light: lightCollection) {
          // .....
      }
      return getLightsStateAsJSON();
   }
  </code></pre>
  
  <p>When I click my button I get the following message:</p>
  
  <p><img src="https://i.stack.imgur.com/o9FtS.png" alt="415 Unsupported MediaType"></p>
  
  <p>According to firefox I do send JSON in my request. At least it says so when I examine the send data.</p>
  
  <p><img src="https://i.stack.imgur.com/ijFdZ.png" alt="Showing JSON data"></p>
  
  <p>This is my header request data:</p>
  
  <p><img src="https://i.stack.imgur.com/sMNnD.png" alt="Header content"></p>
  
  <p>What am I missing here?</p>