Reputation: 310
I'm three20 for first time on an iOS app, and I'm stuck on something I can find more information.
I'm trying to send some POST data to my local server, but everytime I got a response : Error. If I try with GET parameters I have no problem.
The code I'm using is this :
TTURLRequest *request =
[TTURLRequest requestWithURL:@"http://127.0.0.1:8000/api/login" delegate:self];
request.cachePolicy = cachePolicy;
request.response = [[[TTURLDataResponse alloc] init] autorelease];
request.httpMethod = @"POST";
NSString *myRequestString = @"username=######@gmail.com&password=66Ed############fxij";
NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length ] ];
request.contentType=@"application/x-www-form-urlencoded";
[request.parameters addObject:@"username" forKey:@"######@gmail.com"];
[request.parameters addObject:@"password" forKey:@"6Ed############fxij"];
request.httpBody = myRequestData;
Thank you for your help.
Upvotes: 2
Views: 2438
Reputation: 7649
You have the params backwards too! That could be it. It should be:
[request.parameter addObject:@"####@gmail.com" forKey:@"username"];
Upvotes: 1