Using afnertorking to encounter code-1016 situations

Source: Internet
Author: User

When using AfnetworKing's time., you will often encounter thisProblem, onlineMany of the methods areToSelf.acceptablecontenttypes = [Nsset setwithobjects:@ "Application/json", @ "Text/json", @ "Text/javascript", nil] Add Field text/html,But IAfter adding, orNoTo be successful.Request down data,Later, resistant toLook at the wrong reason, the original is toAdd TExt/plainFieldSo it's in the codeAdd the following line of code in the
manager.responseSerializer.acceptableContentTypes = [Nsset setwithobject:@ "Text/plain"];
Can successfully request down the data.
Attached to the demo I wrote:

Write your own demo using afnetworking for post requests
Afhttprequestoperationmanager * Manager = [Afhttprequestoperationmanager manager];
The result of declaring a request is a JSON type
Manager.responseserializer = [Afjsonresponseserializer serializer];
Add fields that can be requested
Manager.responseSerializer.acceptableContentTypes = [Nsset setwithobject:@ "Text/plain"];

http://ipad-bjwb.bjd.com.cn/digitalpublication/publish/handler/apinewslist.ashx?date=20131129& startrecord=1&len=5&udid=1234567890&terminaltype=iphone&cid=213
Nsdictionary * parameters = @{@ "date": @ "20131129", @ "Startrecord": @ "1", @ "len": @ "5" @ "Udid": @ "1234567890", @ " Terminaltype ": @" Iphone "@" CID ": @" 213 "};
NSString * URL [email protected] "Http://ipad-bjwb.bjd.com.cn/DigitalPublication/publish/Handler/APINewsList.ashx? date=20131129&startrecord=1&len=5&udid=1234567890&terminaltype=iphone&cid=213 ";

[Manager Post:url Parameters:parameters success:^ (afhttprequestoperation * _nonnull operation, id _Nonnull Responseobject) {
NSLog (@ "JSON =%@", responseobject);
} failure:^ (Afhttprequestoperation * _nonnull operation, Nserror * _nonnull error) {
NSLog (@ "%@", error);

}];

Using afnertorking to encounter code-1016 situations

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.