title: Spring MVC 415 Unsupported Media Type
body: <p>I am using Spring 3.2 and try to use an ajax post request to submit an array of json objects. If this is relevant, I escaped all special characters.</p>
  
  <p>I am getting an HTTP Status of 415. </p>
  
  <p>My controller is:</p>
  
  <pre><code>@RequestMapping(value = "/save-profile", method = RequestMethod.POST,consumes="application/json")
      public @ResponseBody String saveProfileJson(@RequestBody String[] profileCheckedValues){
          System.out.println(profileCheckedValues.length);
          return "success";
      }
  </code></pre>
  
  <p>jquery is:</p>
  
  <pre><code>jQuery("#save").click(function () {
          var profileCheckedValues = [];
          jQuery.each(jQuery(".jsonCheck:checked"), function () {
              profileCheckedValues.push($(this).val());
          });
          if (profileCheckedValues.length != 0) {
              jQuery("body").addClass("loading");
              jQuery.ajax({
                  type: "POST",
                  contentType: "application/json",
                  url: contextPath + "/sample/save-profile",
                  data: "profileCheckedValues="+escape(profileCheckedValues),
                  dataType: 'json',
                  timeout: 600000,
                  success: function (data) {
                      jQuery('body').removeClass("loading");
                  },
                  error: function (e) {
                      console.log("ERROR: ", e);
                      jQuery('body').removeClass("loading");
                  }
              });
          }
      });
  </code></pre>
  
  <p>and an example of one of the objects from the array I am posting is the following json: </p>
  
  <pre><code>{
    "id": "534213341",
    "name": "Jack Lindamood",
    "first_name": "Jack",
    "last_name": "Lindamood",
    "link": "https://www.facebook.com/jack",
    "username": "jack",
    "gender": "male",
    "locale": "en_US",
    "updated_time": "2013-07-23T21:13:23+0000"
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method
  </code></pre>
  
  <p>Why is this error happening - does anyone know?</p>