JSON could not be serialized because of error:
Solution 1:
Had a similar issue. Turned out, it was my PHP script receiving the data and sending back erroneous serialized JSON data. There was an "echo" statement that might have corrupted the serialized data. Check your server-side code, not for error but for an echo statement or other output that should be commented out.
Solution 2:
First try to print in the log if you get any response like this:
Alamofire.request(url, method: .post, parameters: parameter).responseJSON { (response) in
//For Network Error
guard response.result.error == nil else {
print(response.result.error!)
return
}
if let value = response.result.value {
let json = JSON(value)
print("myJSON are: \(json)"
}
}
If this does have any error than tell the server team to check. Also check the app transport security in the plist .
Solution 3:
Struggling with this same error for quite a while, and it did turn out to be a problem on the server side. Use something like Postman to simulate an API call and see what your server responds with.