I'm trying make a POST to codeIgniter webservice, but i always get the same message:
-> [13884:a0b] String sent from server Disallowed Key Characters.
any ideia? thks
define kUrl @"http://gf.kineth.com/index.php/json_api/"
This is my function
-(void)postMessageLogin:(NSString *)login:(NSString *)pass{//Login device selected = 1;
NSMutableString *postString = [NSMutableString stringWithString:kUrl];
//a = 1 melhor variavel do mundo, faz cenas incriveis
[postString appendFormat:@"loginUser?data={\"email\":\"[email protected]\",\"password\":\"123456\"}"];
[postString setString:[postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"%@",postString);
NSString *myRequestString = postString;
NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length ] ];
request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString:kUrl ] ];
[ request setHTTPMethod: @"POST" ];
[ request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
[ request setHTTPBody: myRequestData ];
NSURLConnection * connection = [[NSURLConnection alloc]
initWithRequest:request
delegate:self startImmediately:NO];
[connection scheduleInRunLoop:[NSRunLoop mainRunLoop]
forMode:NSDefaultRunLoopMode];
[connection start];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)theData{ NSLog(@"String sent from server %@",[[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding]);
NSError *error;
NSDictionary *dic;
dic = [NSJSONSerialization JSONObjectWithData:theData options:0 error:&error];
NSLog(@"[SL] JsonPost : didReceiveData %@",dic);
NSLog(@"[SL] JsonPost : didReceiveData %@",error);
[connection cancel];
}