title: Alamofire printing "JSON could not be serialized because of error:"
body: <p>I' m trying to make a post request with some params, but while making the request Alamofire prints the following error:</p>
  
  <blockquote>
    <p>JSON could not be serialized because of error:
    The data couldn’t be read because it isn’t in the correct format.</p>
  </blockquote>
  
  <p>Following is my code I'm trying to run:</p>
  
  <pre><code>var parameters: [String: Any] = [:]
  parameters[UserParameters.kUserId.rawValue] = self.userInfoForMe.user_id
  parameters[UserParameters.kGender.rawValue] = self.userInfoForMe.gender
  parameters[UserParameters.kfull_name.rawValue] = self.userInfoForMe.full_name
  parameters[UserParameters.kDOB.rawValue] = self.userInfoForMe.dob  
  
  print("parameters:\(parameters)")
  let userInfoDataHandler:UserInfoDataHandler = UserInfoDataHandler()
  var DataJSON : JSON = JSON.null
  userInfoDataHandler.postData(parameters: parameters){
      responseObject, error in
      if responseObject != nil{
          DataJSON = JSON(responseObject!)
         print(DataJSON) 
      }
      else{
          self.removeLoader(showNewController: false)
          self.showAlertWithMessage(msg: ErrorContants.somethingWentWrongError)
      }
  }
  </code></pre>
  
  <p>here is my UserDataInfoHandler:</p>
  
  <pre><code>class UserInfoDataHandler: BaseService {
  init(){
      super.init(controller: Controllers.mobile_pa, apiName: ApiNames.save_user_info)
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and following is my code for which gets called from Base Service:</p>
  
  <pre><code>fileprivate func fetchData(method:String, endpoint:String,parameters: [String: Any],completionHandler: @escaping (NSDictionary?, Error?) -&gt; ()){
  
      //need to show loader here..
  
      var request: DataRequest? = nil
      let requestURL : String = URLConstants.baseURL + self.controller + "/" + self.apiName
      switch method {
      case RequestMethod.GET.rawValue:
          request = Alamofire.request(requestURL, method: HTTPMethod.get, parameters: parameters)
  
      case RequestMethod.POST.rawValue:
          request = Alamofire.request(requestURL, method: HTTPMethod.post, parameters: parameters)
  
      default:
          print(ErrorContants.WentThroughSwitchCaseOf + "Base Service");
      }
  
      request?.responseJSON(completionHandler: { (response) in
  //this block never gets executed as it throws error that JSON is not serialized.
              self.checkForResponseAndError(response: response, completionHandler: completionHandler)
          })
  }
  </code></pre>
  
  <p>After printing my parameters, the following is the output,</p>
  
  <pre><code>parameters:[ "full_name": "fatin", "user_id": "42", "dob": "06-12-1994", "gender": "1"]
  </code></pre>
  
  <p>Update: I have tried working with other post request and parameters with same code, they are working fine. So I came to know that it's problem with my parameters that I'm sending, but still can't figure out what's going wrong.</p>