title: Swift 3 Alamofire 4 Upload array of images with parameters
body: <p>I'm trying to upload an array of pictures along with some parameters using Alamofire 4 and Swift 3.</p>
  <p>The parameters seem to work because the update is done, but the images don't get to the server</p>
  <p>In Postman I can do this fine with no problem:</p>
  <p><a href="https://i.stack.imgur.com/MsLQr.png" rel="nofollow noreferrer">Postman request sample</a></p>
  <p>This is my code so far:</p>
  <pre><code>    let parameters = [
          &quot;service_request_id&quot; : servicesID,
          &quot;status_id&quot; : &quot;4&quot;,
      ]
      Alamofire.upload(
          multipartFormData: { multipartFormData in
              
              for (key,value) in parameters {
                  if let value = value as? String {
                      multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
                  }
              }
              
              for (image) in self.imagesArray {
                  if  let imageData = UIImageJPEGRepresentation(image, 1) {
                      multipartFormData.append(imageData, withName: &quot;image&quot;, fileName: &quot;image.jpeg&quot;, mimeType: &quot;image/jpeg&quot;)
                  }
              }
      },
          to: ConnectionWS.UpdateServicesURL,
          method: .put,
          encodingCompletion: { encodingResult in
              switch encodingResult {
              case .success(let upload, _, _):
                  
                  upload.uploadProgress(closure: { (progress) in
                      print(progress)
                  })
                  
                  upload.responseJSON { response in
                      
                      // If the request to get activities is succesfull, store them
                      if response.result.isSuccess{
                          print(response.debugDescription)
                          alert.dismiss(animated: true, completion:
                              {
                                  self.dismiss(animated: true, completion:
                                      {
                                          self.delegate?.statusChanged(IsFinish: false)
                                  })
                                  
                          })
                          
                          // Else throw an error
                      } else {
                          
                          
                          var errorMessage = &quot;ERROR MESSAGE: &quot;
                          if let data = response.data {
                              // Print message
                              let responseJSON = JSON(data: data)
                              if let message: String = responseJSON[&quot;error&quot;][&quot;message&quot;].string {
                                  if !message.isEmpty {
                                      errorMessage += message
                                  }
                              }
                          }
                          print(errorMessage) //Contains General error message or specific.
                          print(response.debugDescription)
                      }
                      
                      alert.dismiss(animated: true, completion:
                          {
                              self.dismiss(animated: true, completion:nil)
                              
                      })
                  }
              case .failure(let encodingError):
                  print(&quot;FALLE ------------&quot;)
                  print(encodingError)
              }
      }
      )
  </code></pre>
  <p>Am I doing something wrong?</p>
  <p>Please help.</p>