I'm having some trouble with RESTfull web service and I'm trying to see my request as a text using NSLog. I tried this:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
...
[manager POST:urlString parameters:mutableParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
...
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Response: %@", [operation description]) ;
if (block) {
block(error);
}
NSLog(@"-------------------------------");
NSLog(@"Request: %@", manager.requestSerializer.debugDescription);
NSLog(@"-------------------------------");
NSLog(@"Request: %@", manager.requestSerializer.description);
NSLog(@"-------------------------------");
NSLog(@"Request: %@", operation.request.HTTPBodyStream);
NSLog(@"-------------------------------");
NSLog(@"Request: %@", operation.request);
NSLog(@"-------------------------------");
NSLog(@"Error: %@", error);
NSLog(@"-------------------------------");
}];
Is there any way to NSLog the request from AFHTTPRequestOperationManager (AFNetworking 2) ?
Have a look to the POST method:
[manager POST:urlString parameters:mutableParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
You have a AFHTTPRequestOperation *operation and an id responseObject in the success block.
The best thing that you can do is to put a:
NSLog(@"AFHttpRequestOperation %@", operation);
and set there a breakpoint so you can inspect what's happening there:

What do you want to see about the operation's request?
Not exactly logging but this answer explains how to convert NSURLRequest to NSString
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With