title: 415 (Unsupported Media Type) with jquery
body: <p>I am new to using a RESTful API and I don't know why it is showing this error.
  I am posting the values through jQuery. Do I need to do something else? This is my jQuery code:</p>
  
  <p>Updated : Now it is showing  <strong>405 (Method Not Allowed)</strong></p>
  
  <pre><code> $(document).ready(function(){ 
  
  
  $("#patsubmit").click(function() {
      var firstName = $("#firstName").val();
      var lastName = $("#lastName").val();
      var mobileNumber = $("#mobileNumber").val();
      var emailId = $("#emailId").val();
  
     var dataString = '{"firstName":"'+ firstName + '","lastName":"' + lastName + '","mobileNumber":"' + mobileNumber + '", "emailId":"' + emailId+'"}';
     console.log(dataString); 
     if(firstName=='' )
      {
  alert("nothing in it");
      }
      else
      {
      $.ajax({
      type: 'POST',
       url : '/geniedoc/api/patient/register',
       data: dataString,
       contentType: 'application/json',
       dataType: 'json',
       headers: {'Content-Type':'application/json'}
      success: function(){ // Uncaught SyntaxError: Unexpected identifier
  console.log();
     }
  });}
      return false;
      });
  
  });
  </code></pre>
  
  <p>This is my Java API. <code>MAIN_PATIENT</code> = <code>api/patient</code> and <code>RestURIConstants.REGISTER</code> = <code>register</code>   </p>
  
  <pre class="lang-java prettyprint-override"><code>@RestController
  @RequestMapping(value = RestURIConstants.MAIN_PATIENT)
  public class PatientRestController extends AbstractController implements RestURIConstants, GenieDocConstants{
  
      private static final Logger logger = Logger.getLogger(UserRestController.class);
  
      @RequestMapping(value = RestURIConstants.REGISTER, method = RequestMethod.POST, consumes ="application/json")
      public @ResponseBody ModelMap registerPatient(HttpServletRequest  request, @RequestBody PatientVo patientVo){
          logger.info("registerPatient : Start");
          long startTime = System.currentTimeMillis();
          ModelMap map = new ModelMap();
          PatientVo patVo;
          try {
              if(patientVo.getFirstName() == null) {
                  map.addAttribute(STATUS_CODE, FAILURE);
                  map.addAttribute(STATUS_MESSAGE, this.env.getProperty(MESSAGE_FIRST_NOT_EMPTY));
              } else if(patientVo.getEmailId() == null) {
                  map.addAttribute(STATUS_CODE, FAILURE);
                  map.addAttribute(STATUS_MESSAGE, this.env.getProperty(MESSAGE_EMAIL_NOT_EMPTY));
              } else if(patientVo.getEmailId() == "") {
                  map.addAttribute(STATUS_CODE, FAILURE);
                  map.addAttribute(STATUS_MESSAGE, this.env.getProperty(MESSAGE_EMAIL_NOT_EMPTY));
              } else if (patientVo.getMobileNumber() == null) {
                  map.addAttribute(STATUS_CODE, FAILURE);
                  map.addAttribute(STATUS_MESSAGE, this.env.getProperty(MESSAGE_MOBILE_NOT_EMPTY));
              } else {
                  patVo = this.patientManagementService.provisionPatient(patientVo);
                  if (patVo != null) {
                      map.addAttribute("patientId", patVo.getEmailId());
                      map.addAttribute(STATUS_CODE, SUCCESS_STATUS_CODE_REGPATIENT);
                      map.addAttribute(STATUS_MESSAGE, this.env.getProperty(SUCCESS_STATUS_CODE_REGPATIENT));
  
                  } else {
                      map.addAttribute(STATUS_CODE, ERROR_STATUS_CODE_REG);
                      map.addAttribute(STATUS_MESSAGE, this.env.getProperty(ERROR_STATUS_CODE_REG));
                  }
              }
          } catch (MongoDBDocumentNotFoundException e) {
              map.addAttribute(STATUS_CODE, ERROR_STATUS_CODE_REGPATIENT);
              map.addAttribute(STATUS_MESSAGE,this.env.getProperty(ERROR_STATUS_CODE_REGPATIENT));
              logger.error("Error : " + e.getMessage());
              //e.printStackTrace();
          } catch (UserAreadyExsistException e) {
              map.addAttribute(STATUS_CODE, ERROR_STATUS_CODE_REGPATIENT);
              map.addAttribute(STATUS_MESSAGE, this.env.getProperty(ERROR_STATUS_CODE_REGPATIENT));
              logger.error("Error : " + e.getMessage());
              //e.printStackTrace();
          }
          logger.debug("Exit: Total Time Taken: "+ (System.currentTimeMillis() - startTime));
          return map;
      }
  </code></pre>