平淡迴應我發送POST請求:獲得來自AFNetworking 2.4.1
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
NSDictionary *parameters = @{@"method": @"login", @"email":@"email", @"password":@"password"};
[manager POST:@"http://www.apiwebsite.com" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
我responseObject是:
JSON: <0d0a7b22 72657370 6f6e7365 223a224f 4b222c22 30223a22 6d61696c 696e675f 6b657922 2c223122 3a226239 65653766 34643238 64333730 30666663 37393734 65376665 66626663 3136227d>
但調用API與郵差,我得到:
{"response":"OK", "id":"1234223123"}
如何獲取普通或JSON響應以使用它? 謝謝!
如果我使用''AFJSONResponseSerializer我得到: '錯誤:錯誤域= com.alamofire.error.serialization.response代碼= -1016 「請求失敗:無法接受的內容類型:text/html的」 的UserInfo = 0x8c47a60 ' – pekpon 2014-09-24 16:24:02
@pekpon你設置了'requestSerializer'嗎? – sage444 2014-09-25 07:59:45
我可以在哪裏設置? – pekpon 2014-09-25 08:19:04