iosswiftalamofirealamofire-request

Alamofire assertionFailure - needNewBodyStream did not find UploadRequest


I'm trying to send a POST request using alamofire. but on a request i'm keeping get this error:

   assertionFailure("needNewBodyStream did not find UploadRequest.")


    Alamofire/SessionDelegate.swift, line 178
    2020-12-09 16:48:32.746737+0330 Dericoin[29553:862552] Fatal error: needNewBodyStream did not find UploadRequest.: file Alamofire/SessionDelegate.swift, line 178

my request :

let paramsDict: [String: Any]? = [...]
let headersDict: [String: Any]? = [...]    
AF.request("https://....", method: .post, parameters: paramsDict, encoding: URLEncoding.default, headers: headersDict)
                .responseJSON { response in
                    //something
            }

i'm using Alamofire v5.4 and also tested v5.2 and v5.3; iOS 14 and Swift 5. any suggestion?


Solution

  • It turned out to be a problem with network analytics frameworks ( i was using Wormholy). Those can interfere with Alamofire's internal storage.

    So removing the pod solved the problem. If someone had the same problem wanted to follow the issue; this is the link:

    https://github.com/Alamofire/Alamofire/issues/3373