Error Domain=com.alamofire.error.serialization.response code=-1016

Source: Internet
Author: User
Tags response code serialization

Sometimes a network request with a afnet error can occur: Domain=com.alamofire.error.serialization.response error code=-1016

As shown in the following illustration:



Understand that the client cannot resolve the data returned by the service segment:

PS: digression, this problem is actually the background developers of the pot, did not do a good job return style)

A few years ago with ASI can parse the data, now with afnet, we need to manually add analytic format "text/html";

See some technical Bowen, to get into afnet source file afurlresponseserialization.m; This method is OK, but we try not to change the source code that has been formed, so we need to add it manually in the place where we use Afnet: Manager.responseSerializer.acceptab Lecontenttypes = [Nsset setwithobject:@ "text/html"]; Can


Shaped like:

Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanager manager];


Manager.responseSerializer.acceptableContentTypes = [Nsset setwithobject:@ ' text/html '];//set the appropriate content type


[Manager Post:url Parameters:parameters success:^ (afhttprequestoperation *operation, id responseobject) {


} failure:^ (Afhttprequestoperation *operation, Nserror *error) {


}];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.