I have looked at a lot of posts about http post requests and I still have not been able to find the answer. My problem is that I need to send one string to my work partners website so it can be accessed using a GET request and used for a leader board/
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
[req setHTTPMethod:@"POST"];
NSData *postData = [revs dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
[req addValue:postLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:req
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
// Do something with response data here - convert to JSON, check if error exists, etc....
NSLog(response.description);
// NSLog([[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]);
}];
[task resume];
But the request never goes to the website, it is called ../distances.txt
Can anyone help?