title: Using Alamofire and multipart/form-data
body: <p>I'm unable to approach the API that has been offered to me in the proper way for it to give me the response I'm looking for. I've been using Swift and Alamofire for a while but this is the first time I've to upload images using multipart/form-data. I'm able to upload images using Postman but I'm unable to get the same message send out by my application using the Alamofire framework. </p>
  
  <p><a href="https://i.stack.imgur.com/GKE89.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GKE89.png" alt="My Postman screenshot"></a></p>
  
  <p>My Swift code: </p>
  
  <pre><code>func postFulfilWish(wish_id: Int, picture : UIImage, completionHandler: ((AnyObject?, ErrorType?) -&gt; Void)) {
  
      var urlPostFulfilWish = Constant.apiUrl;
      urlPostFulfilWish += "/wishes/";
      urlPostFulfilWish += String(wish_id);
      urlPostFulfilWish += "/fulfill/images"  ;
  
      let image : NSData = UIImagePNGRepresentation(UIImage(named: "location.png")!)!
  
      Alamofire.upload(.POST, urlPostFulfilWish, headers: Constant.headers, multipartFormData: { multipartFormData in
          multipartFormData.appendBodyPart(data: image, name: "file")
          },
          encodingCompletion: { encodingResult in
              switch encodingResult {
              case .Success(let upload, _, _):
                  upload.responseJSON { response in
                      //This is where the code ends up now
                      //So it's able to encode my message into multipart/form-data but it's not doing it in the correct way for the API to handle it
                      debugPrint(response)
                  }
              case .Failure(let encodingError):
                  print(encodingError)
              }
          }
      )
  }
  </code></pre>