I am using the following code to post an image to my server.
@IBAction func postButtonPressed(sender: UIButton) {
let task = NSURLSession.sharedSession(
I fixed using headers with application/json and sending on the request:
let headers: HTTPHeaders = [
.accept("application/json")
]
AF.request(url, method: .post, parameters: score, encoder: JSONParameterEncoder.default, headers: headers)
Well, in my case simply increasing the timeout of request solved the problem.
Apparently my post request was getting a timeout error since I was sending an image that the server would find too large. I scaled down the images in order to make my images acceptable by the server.
As this post suggests, NSURLErrorDomain Code=-1001
error might be caused by many things including;
Hope that helps to other people
In my case issue was in 3rd party library - FirebasePerformance
.
Bug report URL: https://github.com/firebase/firebase-ios-sdk/issues/486
It is late to reply but I recently face the error while running the new application assigned to me. The application is one of them whose URL Domains are blocked by the system administrator of my company.
I ask them to allow me the URL access after which the response came and the application run perfectly.
This may be not the actual solution for everyone but some of the developers may have the restricted environment can get help by this.