I am using the JSON string as a request to the server and get the response in the JSON format. I have used this code for posting the data,
NSString *requestString = [NSString stringWithFormat:@"{\"id\":\"1\"}}"];
NSLog(@"the request string is %@", requestString);
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @"http//www.aaaa.com"]];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: requestData];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
[theConnection start];
if( theConnection ){
receiveData = [[NSMutableData data] retain];
}
In server side, they have used core PHP with post method, whenever i sent the request to the server, i am not getting the data and JSON request file doesn't reached to the server. So please help me out.
But the above code is perfectly working fine in the another project and they have used SOAP in the server side. So please suggest me, where can i change the code to achieve this, in server side or iPhone side.
Thanks!