Those requests are not exactly the same.
C# example sends POST request to /DebugUser
with query params ?userName=<username>&password=<password>
, obj-c one sends POST request to /
with form-urlencoded data userName=<username>&password=<password>
. I guess that problem is this small mistake in URI path (mostly those small, stupid mistakes takes more time to solve than real problems.. ;) ). Additionally I would suggest to url encode params, in this example your username me@inc.com
should be encoded as me%40inc.com
to be valid url/form-url encoded data. See also my code-comment about ivar.
Something like that should work (written on the fly, I haven't compile that / check before posting):
-(void)try10{
NSString *user = @"me%40inc.com";
NSString *pwd = @"myEazyPassword";
NSString *myURLString = [NSString stringWithFormat:@"http://192.168.1.10:8080/DebugUser?username=%@&password=%@",user,pwd];
NSMutableURLRequest *request = [NSMutableURLRequest new];
[request setURL:[NSURL URLWithString:myURLString]];
[request setHTTPMethod:@"POST"];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(theConnection){
// I suppose this one is ivar, its safer to use @property
// unless you want to implement some custom setters / getters
//webData = [NSMutableData data];
self.webData = [NSMutableData data];
NSLog(@"connection initiated");
}
}