Why Won't this http post request work?
- by dubbeat
Hi,
I'm wondering why this http post request won't work for my iphone app.
I know for a fact that the url is correct and that the variables I'm sending are correct but for some reason the request is not being recieved by the aspx page.
NSMutableString *httpBodyString;
NSURL *url;
NSMutableString *urlString;
httpBodyString=[NSMutableString stringWithFormat:@"%@%@%@%@%@",@"?g=",promoValueObject.country,@"&c=",promoData.artistid,@"&d=iphone"];
urlString=[[NSMutableString alloc] initWithString:@"http://www.mysite.com/stats_promo.aspx"];
url=[[NSURL alloc] initWithString:urlString];
[urlString release];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
[url release];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[httpBodyString dataUsingEncoding:NSISOLatin1StringEncoding]];
//[httpBodyString release];
NSURLConnection *connectionResponse = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
if (!connectionResponse)
{
NSLog(@"Failed to submit request");
}
else
{
NSLog(@"--------- Request submitted ---------");
NSLog(@"connection: %@ method: %@, encoded body: %@, body: %a", connectionResponse, [urlRequest HTTPMethod], [urlRequest HTTPBody], httpBodyString);
}