NSMutableURLRequest response null

82 views Asked by At

I am trying to make a POST request with encrypted string using following code. In response I get null from server. I test with this https://www.hurl.it using same value and get 200. Can't figure out where is the problem.

To encode string I have use

NSUTF8StringEncoding NSASCIIStringEncoding NSNEXTSTEPStringEncoding

forD = @"AAAAAAAAAMCYdiQv+wcAsBAAAAAAAAAAaQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMQswCQYDVQQGEwJVUzETMBEGA1UECBMKTkVXIEpFUlNFWTEZMBcGA1UEChMQVkVSSVpPTiBXSVJFTEVTUzENMAsGA1UECxMETUlQUzEbMBkAAAAAAAAAwAAAAAAAAADACABUSUNTLTAxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABUfCQv+wcA8L4GJC/7BwAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1ZwkL/sHAFCDeyQv+wcQAA==";

NSData* requestData = [forD dataUsingEncoding:NSASCIIStringEncoding];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:baseURL]];
[request setHTTPMethod:@"POST"];

[request setValue:@"1" forHTTPHeaderField:@"Appversion"];
[request setValue:@"*/*" forHTTPHeaderField:@"Accept"];
[request setValue:@"gzip,deflate" forHTTPHeaderField:@"Accept-Encoding"];

[request setHTTPBody: requestData];

NSLog(@"%@", [request allHTTPHeaderFields]);
NSLog(@"%@", [request HTTPBody]);

NSURLResponse *response;
NSError *error = nil;
NSData *receivedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

NSLog(@"\n\n === RESPONSE SERVER ==== \n\n %@",[NSJSONSerialization JSONObjectWithData:receivedData options:0 error:nil]);
0

There are 0 answers