I want to send a JSON String to server using AFNetworking POST request. Currently I am trying following code
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSData * data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:data];
[request setTimeoutInterval:120];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
AFHTTPRequestOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject)
{ NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"Error: %@", error);
}];
[operation start];`
Nothing is happening. The code neither enters success block nor the failure block. What can be the reason? Is there any alternate way of doing this in AFNetworking 2. NOTE: Request is working perfectly on POSTMAN and returns response in less than 500 ms.