Reputation: 6394
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) ?
Upvotes: 3
Views: 2096
Reputation: 2107
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
Upvotes: 4