This code snippet isn't working, I'm getting an "Authentication Failed." response from the server. Any ideas?
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
initWithURL:
[NSURL URLWithString:@"http://www.tumblr.com/api/write"]];
[request setHTTPMethod:@"POST"];
[request addValue:_tumblrLogin forHTTPHeaderField:@"email"];
[request addValue:_tumblrPassword forHTTPHeaderField:@"password"];
[request addValue:@"regular" forHTTPHeaderField:@"type"];
[request addValue:@"theTitle" forHTTPHeaderField:@"title"];
[request addValue:@"theBody" forHTTPHeaderField:@"body"];
NSLog(@"Tumblr Login:%@\nTumblr Password:%@", _tumblrLogin, _tumblrPassword);
[NSURLConnection connectionWithRequest:request delegate:self];
[request release];
Both _tumblrLogin
and _tumblrPassword
are run through stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding
elsewhere in my code. My login email is of the form "[email protected]". It works just fine for logging in directly to tumblr, but I'm wondering if the "+" character is causing problems with the encoding? It's not being escaped. Should it be?
Thanks to Martin's suggestion, I'm now using CFURLCreateStringByAddingPercentEscapes
to escape my login and password. I'm still having the same issue, though, my Authentication is failing.