私は最近、自分のプロジェクトで AfNetworking を使い始めました。私はAFClientを作成し、すべてのパラメーターを実装し、すべてがメソッドを取得するためのものです。ただし、POSTメソッドを作成することはできません: 私のコードがあります:
NSDictionary *params = [[NSDictionary alloc]initWithObjectsAndKeys:
@"TexttoInsert", @"question",
id,@"user_id",
nr1,@"number1",
nr2, @"number2",
nil];
[[MYClient sharedInstance] postPath:@"insert" parameters:params success:^(AFHTTPRequestOperation *operation, id JSON) {
NSLog(@"%@", JSON);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"RequestOperation:%@",operation);
NSLog(@"Error:%@",error);
}];
このエラーが発生し、解決できません。
Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 400" UserInfo=0x6cb6330 {NSLocalizedRecoverySuggestion={"success":false,"error":400,"message":"Bad Request"},
AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x6a893e0>, NSErrorFailingURLKey=http://myMainUrl/insert, NSLocalizedDescription=Expected status code in (200-299), got 400, AFNetworkingOperationFailingURLRequestErrorKey=<NSMutableURLRequest http://myMainUrl/insert>}