Code:
arrValues = [[NSMutableArray alloc]initWithObjects:@"Chennai", nil];
arrKeys = [[NSMutableArray alloc]initWithObjects:@"loc", nil];
dicValue = [NSDictionary dictionaryWithObjects:arrValues forKeys:arrKeys];
NSString *strMethodName = @"agentuserlist";
strUrlName = [NSString stringWithFormat:@"%@%@?filters=%@",appDelegate.strURL, strMethodName, dicValue];
//strUrlName = [strUrlName stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:strUrlName] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:250.0];
[request setHTTPMethod:@"GET"];
[request setHTTPShouldHandleCookies:YES];
[request setValue:@"zyt45HuJ70oPpWl7" forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
NSError *error;
NSURLResponse *response;
NSData *received = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response error:&error];
NSLog(@"error:%@", error);
NSString *strResponse = [[NSString alloc]initWithData:received encoding:NSUTF8StringEncoding];
NSLog(@"response :%@", strResponse);
I try to send json argument through get method.It gives error as "unsupported url(-1002)"
.
The URL is working fine when I checked with Postman. I am unable to find out the problem.
Where I went wrong?