Ryan Bigg Ryan Bigg - 9 months ago 70
Swift Question

Expression type '()' is ambiguous without more context

I'm trying to do an upload with Alamofire using this code (where photo.image is a UIImage)

let imageData = UIImageJPEGRepresentation(photo.image, 1.0)

multipartFormData: { multipartFormData in
multipartFormData.append(data: imageData!, withName: "unicorn")
to: "https://httpbin.org/post",
encodingCompletion: { encodingResult in
switch encodingResult {
case .success(let upload, _, _):
upload.responseJSON { response in
case .failure(let encodingError):

However, this tells me "Expression type '()' is ambiguous without more context.

I am not sure what I'm doing wrong here and would love some advice.


I had the wrong arguments for multipartFormData. Here's what worked:

multipartFormData: { multipartFormData in
                    multipartFormData.append(imageData!, withName: "photo", fileName: "image.jpg", mimeType: "image/jpg")