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