Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:]

最近在测试项目通过AFNetWorking进行网络请求遇到一个错误,代码很简单,就是一个Get请求:

` AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

AFHTTPRequestOperation *requestOperation = [manager GET:urlString parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"Success-FlyElephant");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error--FlyElephant");
}];
`

运行的时候遇到错误:

Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:]

分析了一下请求的Url,发现其中有些参数中包含有有空格,需要重新Encode一下:

NSString *encodeUrl = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

你可能感兴趣的:(Assertion failure in -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:])