// 请求头里面的参数最好都写
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager.requestSerializer setValue:@"application/json;charset=utf-8" forHTTPHeaderField:@"Content-Type"]; // 设置请求头里面的host [manager.requestSerializer setValue:@"api.wusejia.com" forHTTPHeaderField:@"Host"]; // 防止参数被AFNetworking转码 [manager.requestSerializer setQueryStringSerializationWithBlock:^NSString * _Nonnull(NSURLRequest * _Nonnull request, id _Nonnull parameters, NSError * _Nullable __autoreleasing * _Nullable error) { return parameters; }]; // 设置body体 [manager POST:@"http://api.wusejia.com/auth/mobile" parameters:@"{"password":"jian199311043658","cellphone":"18242366101"}" progress:^(NSProgress * _Nonnull uploadProgress) { } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { // 请求成功 NSLog(@"%@",task.currentRequest); NSLog(@"%@", [task.currentRequest allHTTPHeaderFields]); NSLog(@"%@", responseObject); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { // 请求失败 }];