I'm new to the iOS development.
I'm using the following code to send a request the server and get response synchronously.
My request contains JSON object. When I run on simulator I got error "Bad URL".
Please help me to solve this issue.
NSString *regUrlWithJson = @"https://dso.mpl.com/reg?json={\"operation\":\"login\",\"contactEmail\":\"abc@rt.com\",\"password\":\"e3dba1bbfab020a2eb105c69405a7766\",\"SSO\":\"true\",\"service\":\"lp\",\"sig\":\"true\",\"url\":\"mpl\"}";
NSLog(regUrlWithJson);
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:regUrlWithJson]];
NSURLResponse * response = nil;
NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
if (error != nil)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
else{
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login" message:string delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
Thanks,