This problem occurs when using Afnetworking 3.0:
Error domain=com.alamofire.error.serialization.response code=-1016 "Request failed:unacceptable content-type:text/ Plain
Here is the code show
1 Error domain=com.alamofire.error.serialization.response code=-1016 "Request Failed:unacceptable content-type:text/plain"
Or
1 Error domain=com.alamofire.error.serialization.response code=-1016 "Request Failed:unacceptable content-type:text/html"
This error occurs because the content type returned to the client by the server is Text/plain or text/html format, and afnetworking cannot accept these content types.
If you cannot accept any type, set or add this type. Here take Text/plain as an example.
Workaround 1: Set the AFN default resolution type
1 afhttpsessionmanager *mgr = [Afhttpsessionmanager manager];
1 mgr.responseSerializer.acceptableContentTypes = [Nsset setwithobjects:@ "text/plain ", nil];
The disadvantage of this approach is that after you set Text/plain to accept types, you cannot complete other types of parsing such as Text/json.
Workaround 2: Add the Text/plain and text/html formats to the AFN source file afurlresponseserialization.m.
Modify the No. 228 line of the file
1 self.acceptablecontenttypes = [Nsset setwithobjects:@ "application/json"@ "Text/json"@ "text/javascript", nil];
For
1 self.acceptablecontenttypes = [Nsset setwithobjects:@ "application/json"@ "text/json"@"text/javascript",@ "text/plain ", nil];
or for
1 self.acceptablecontenttypes = [Nsset setwithobjects:@ "application/json"@ "text/json"@"text/javascript",@ "text/html ", nil];
Add an unacceptable content type to resolve.
Workarounds for unacceptable content type errors when using the afnetworking framework