I am using a webservice which takes json object as parameter. Here's my code:
-(void)createHttpHeaderRequest {
NSString *x = @"{\"GetVehicleInventory\": {\"ApplicationArea\": {\"Sender\": {\"ComponentID\":}}}" (something like that)
NSString *sample = [NSString stringWithFormat:@"https://trialservice.checkitout?XML_INPUT=%@",x];
NSString * final = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)sampleReq, NULL, CFSTR(":/?#[]@!$&'()*+,;=\""), kCFStringEncodingUTF8);
NSMutableRequest *request = [NSMutableREquest requestWithURL:[NSURL URLWithString:final]];
NSURLConnection * theConnection = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];
if (theConnection) {
NSLog(@"Service hit");
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSError * error;
NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
NSArray * categories = [dict objectForKey:@"category"];
[self.delegate giveControlBackToController:categories];
}
When I am trying to NSLog sample it gives me the complete URL which on pasting into a browser gives me the result back, but when I am calling NSLog on the request, it shows null and nothing happens after this. The control never goes to its NSURLConnection delegate method.