Cannot Post to site using Xcode. -
OK, I can actually use a little help. I'm very new to coding in xcode (this is also the first time I've asked for help on any site). I need to make a call on the ASP page which is with its previous variable I have tried the code below, but nothing is working.
When I type it in URL then it works fine.
Although I have tried the variations of the code below and nothing is working
NSString * post = @ "longitude = "; Post = [post stringbapping string: longte]; Post = [post stringbapping string: @ "& latitude ="]; Post = [post stringbapping stringing: late]; Post = [post stringbapping string: @ "& device ="]; Post = [post stringbafing string: device id id]; Post = [post stringbapping string: "" & user name = "]; Post = [post stringbuffing string: username. Text]; Post = [post stringbapping string: @ "& service ="]; Post = [post stringbapping string;: subject.text]; Post = [post stringbapping string: @ "and comments ="]; Post = [post stringBeffing string: comments.text]; // post = [[NSString alloc] initWithFormat: @ "& latitude =% @", longt]; NSDTA * PostData = [Post Data Usage Encoding: NSSEIITITING Encoding Permission Loansy Conversion: Yes]; NSString * postLength = [NSString stringWithFormat: @ "% d", [PostData Length]]; NSString * lsUrl = @ "http: //devi.asp"; LsUrl = [lsUrl stringbapping string: post]; NSMutableURLRequest * Request = [[[NSMutableURLRequest alloc] init] autorelease]; [Request URL: [NSUr URL with string: LSURL]]; [Set http system: @ "post"]; [Set set property: post length for http header field: @ "content-length"]; [Request Set Value: @ "App / X-www-Form-URLXode" forHTTPHeaderField: @ "Content-Type"]; [Set http: bb: postdata]; NSURLConnection * conn = [[NSURLConnection alloc] initWithRequest: Request Rep: Self];
It seems that you are complying to apply something in the post method Using URL Parameters through an HTTP GET Method When you type in the URL and it works, I suppose that you mean in the browser URL bar, this means that it is doing a GET, a post No.
Instead of trying to collect your URI parameter and paste it into a POST message body, you should add it to your URL and make a simple GET request using NSURLRequest to try something like this:
NSString * lsUrl = [NSString stringWithFormat: @ "http: //devi.asp%@", post]; NSURLRequest * Request = [[NSURLRequest alloc] initWithURL: lsUrl]; NSURLResponse * response; NSError * error; NSData * Result = [NSURLConnectionSynchronousRequest Send: Request Returning Response: Response Error: & amp; Error];
Comments
Post a Comment