title: 400 Bad request or 415 Unsupported Media type in Ajax post call
body: <p>I have created a POST rest controller in spring. I want to call this controller from a ajax call.</p>
  
  <pre><code>@RequestMapping(value = "/getAdzAcrVehicle")
  @RestController("AdzoneAcrVehicle")
  public class AdzoneAcrVehicleController {
  
  private static Logger LOG = Logger.getLogger(AdzoneAcrVehicleController.class.getName());
  
  private String jsonresponse;
  @Autowired
  @Qualifier(value="AzoneAcrVehicleService")
  private AzoneAcrVehicle azoneAcrVehicle;
  @RequestMapping(method = RequestMethod.POST)
  public String getAll(@RequestBody ObjectNode json) {
         System.out.println(json);
      return json.get("vehicle").asText();
  }
  }
  </code></pre>
  
  <p>I am trying to call that rest controller by using all below provided solutions, But I am getting 400 Bad request or 415 Unsupported Media type error.</p>
  
  <p>1)</p>
  
  <pre><code>var parameter = JSON.stringify({vehicle:datas[3]});
                   $.ajax({
                          url: appName+'/getAdzAcrVehicle',
                          type: 'post',
                          dataType: 'json',
                          success: function (data) {
                             console.log(data);
                          },
                          data: parameter
                      });
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>                 $.ajax({
                      type: 'post',
                      url: appName+'/getAdzAcrVehicle',
                      data: JSON.stringify(parameter),
                      contentType: "application/json; charset=utf-8",
                      traditional: true,
                      success: function (data) {
                      console.log(data);
                      }
                  }); 
  </code></pre>