In my app I am sending a ASI HTTP post request so I user can post a review to my web service however I'm having some trouble sending the request it always seems to be failing I'm sure its a simple error I'm over looking but its driving me made.
My Create Review Class is as follows:
-(void)Submit
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://furious-ice-356.heroku.com/places/%@/reviews.xml",self.identifier]];
//[NSURL URLWithString:[NSString stringWithFormat:@"https://furious-ice-356.heroku.com///places/%@/reviews.xml",self.identifier]];
self.bestnight.text = @"Monday";
ASIFormDataRequest *request1 = [ASIFormDataRequest requestWithURL:url];
[request1 setUsername:self.username];
[request1 setPassword:self.password];
[request1 setRequestMethod:@"POST"];
[request1 setPostValue:self.bestnight.text forKey:@"review[best-night]"];
[request1 setPostValue:self.comments.text forKey:@"review[comments]"];
[request1 setPostValue:self.rating.text forKey:@"review[rating]"];
[request1 setDelegate:self];
[request1 startAsynchronous];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"FINISH Response received: %@", [request responseString]);
UIAlertView * av = [[[UIAlertView alloc] initWithTitle:@"Thank You" message:@"Your review was successfully posted. Thank You for making our App Better." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] autorelease];
[av show];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"FAILED Response received: %@", [request responseString]);
}
Try adding:
[request setShouldPresentCredentialsBeforeChallenge:NO];
Or if that doesn't work, try calling the same but passing 'YES'. Also as others have said double check your username/password.