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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.