ポストマンに、我々はここではバイナリ
の下にそうであるように、私は、バイナリとして画像をアップロードすると画像をアップロードする方法その要求がないようです私のコード
var url = myURLString
url = url.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
guard let imageData = UIImageJPEGRepresentation(image, 0.4) else {
return
}
request.httpBody = imageData
request.httpMethod = "POST"
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
Alamofire.request(request).responseJSON { (response) in
if let JSON = response.result.value as? NSDictionary {
print(JSON)
} else {
let message = response.result.error != nil ? response.result.error!.localizedDescription : "Unable to communicate."
print(message)
}
}
です画像ファイルを添付して、次のエラーメッセージを返す
"レスポンスをシリアル化できませんでした。入力データはゼロまたは長さゼロでした。
理由だけではなく、 'Alamofire.upload(...)'を使わないのでしょうか? – user28434
[alamofire.error Code = -6006 "JSONをシリアル化できませんでした]の重複している可能性があります(https://stackoverflow.com/questions/35374798/alamofire-error-code-6006-json-could-not-be-serialized) – AshvinGudaliya
'responseJSON'ではなく' responseString'を試して、どんなエラーが出ているのか確認してください。 –