title: How to call post request using application/x-www-form-urlencoded which having following parameters in swift 4
body: <p><a href="https://i.stack.imgur.com/ku8Um.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ku8Um.png" alt="postman body screen shot" /></a><a href="https://i.stack.imgur.com/ZrTMT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZrTMT.png" alt="Postman header screen shot" /></a>I would like to call post api which having content type of application/x-www-form-urlencoded. and its request parameters are following :</p>
  <p>CommunityID:24
  FormID:21
  FormData:{&quot;FormID&quot;:&quot;21&quot;,&quot;userResponse&quot;:[{&quot;FormFieldID&quot;:&quot;FormFieldID1&quot;,&quot;RptHeader&quot;:&quot;Name&quot;,&quot;userData&quot;:&quot;mahesh&quot;},{&quot;FormFieldID&quot;:&quot;FormFieldID2&quot;,&quot;RptHeader&quot;:&quot;Mobile Number&quot;,&quot;userData&quot;:&quot;7788556699&quot;},{&quot;FormFieldID&quot;:&quot;FormFieldID3&quot;,&quot;RptHeader&quot;:&quot;Email&quot;,&quot;userData&quot;:&quot;mahesh@gmail.com&quot;},{&quot;FormFieldID&quot;:&quot;FormFieldID3&quot;,&quot;RptHeader&quot;:&quot;Position&quot;,&quot;userData&quot;:&quot;tester&quot;},{&quot;FormFieldID&quot;:&quot;FormFieldID3&quot;,&quot;RptHeader&quot;:&quot;Employment Status&quot;,&quot;userData&quot;:&quot;employee&quot;}]}</p>
  <p>I called this API. and i got response success but in backend side all is going null.</p>
  <p>when i called this API</p>
  <pre><code> var myArrayDatatoSend = [[String:Any]]()
   var addingData  = [[String:Any]]()
   var i : Int = 0
      for item in self.textformsArray{
          self.addingData = [[
              &quot;FormFieldID&quot;:&quot;\(self.formArrayJson[i][&quot;FormFieldID&quot;].stringValue)&quot;,
              &quot;userData&quot;:&quot;\(item)&quot;,
              &quot;RptHeader&quot;:&quot;\(self.formArrayJson[i][&quot;FormFieldHint&quot;].stringValue)&quot;
              ]]
          self.myArrayDatatoSend.append(contentsOf: self.addingData)
          i += 1
      }
    func callCreateForm()  {
       guard let communityID = UserDefaults.standard.value(forKey: &quot;CommunityID&quot;) as? String  else{return}
  
  let parameter : [String : Any] = [&quot;FormID&quot;:self.formID,&quot;CommunityID&quot;:communityID,&quot;FormData&quot;:[&quot;FormID&quot;: self.formID, &quot;userResponse&quot;:self.myArrayDatatoSend]]
   let requestURL: String = Constants.Development.baseURL+Constants.EndPoints.CreateFormData
      let headers = getRequestHeader1(mobileNo: UserDefaults.standard.value(forKey: &quot;myAccount&quot;) as! String)
    //  print(&quot;this is para info : - \(paraInfo)&quot;)
      Alamofire.request(requestURL, method: .post, parameters: paraInfo,encoding: JSONEncoding.default, headers: headers).responseJSON { (response) in
          print(&quot;this is create form response : - \(response)&quot;)
          if (response.result.isSuccess) {
              let httpStatusCode = response.response?.statusCode
              let swiftyJsonVar = JSON(response.result.value!)
              completionHandler(Result.Success(swiftyJsonVar, statusCode: httpStatusCode!))
          }
          else {
              let currentHttpStatusCode:Int?
              currentHttpStatusCode = response.response?.statusCode
              let (message, statusCode) = self.getRequestFailureStatus(requestStatusCode: currentHttpStatusCode)
              completionHandler(Result.Failure(errorMessage: message, httpStatusCode: statusCode))
          }
      }
  }
   func getRequestHeader1(mobileNo : String) -&gt; [String:String] {
      return [&quot;Content-Type&quot;:&quot;application/x-www-form-urlencoded&quot;,
              &quot;MobileNo&quot;:mobileNo,
              &quot;DeviceID&quot;:DeviceId]
  }
  </code></pre>
  <p>When I Called API i got success from API but in backend data not stored it shows null. At backend side request formData key received this kind of format.</p>
  <pre><code>[&quot;FormID&quot;: &quot;21&quot;, &quot;userResponse&quot;: [[&quot;RptHeader&quot;: &quot;Name&quot;, &quot;FormFieldID&quot;: &quot;FormFieldID1&quot;, &quot;userData&quot;: &quot;Prashant&quot;], [&quot;FormFieldID&quot;: &quot;FormFieldID2&quot;, &quot;RptHeader&quot;: &quot;Mobile Number&quot;, &quot;userData&quot;: &quot;9876543210&quot;], [&quot;userData&quot;: &quot;prashant@gmail.com&quot;, &quot;FormFieldID&quot;: &quot;FormFieldID3&quot;, &quot;RptHeader&quot;: &quot;Email&quot;], [&quot;FormFieldID&quot;: &quot;FormFieldID3&quot;, &quot;userData&quot;: &quot;dot net developer &quot;, &quot;RptHeader&quot;: &quot;Position&quot;], [&quot;userData&quot;: &quot;employee &quot;, &quot;RptHeader&quot;: &quot;Employment Status&quot;, &quot;FormFieldID&quot;: &quot;FormFieldID3&quot;]]]
  </code></pre>