Pinku
Pinku

Reputation: 1

How to post data through ASIHTTPRequest in iphone

How to post form field data (name, email,phonenumber,score) through ASIHTTPRequest. I am using json webservices.

Upvotes: 0

Views: 2194

Answers (1)

Karthikeyan
Karthikeyan

Reputation: 1790

Try this , assign variable in your header class

ASIFormDataRequest *requestASI;

in your .m file

 -(void)startASIRequest {

NSString *strUrl = [NSString stringWithFormat:@"http://your url"];

NSURL *url = [NSURL URLWithString:strUrl];

[self setRequestASI:[ASIFormDataRequest requestWithURL:url]];

[requestASI setDelegate:self];

[requestASI setRequestMethod:@"POST"];

[requestASI setPostValue:@"1" forKey:@"name"];

 [requestASI setDidFailSelector:@selector(uploadFailed:)];

[requestASI setDidFinishSelector:@selector(uploadFinished:)];

[requestASI startAsynchronous];


   - (void)uploadFinished:(ASIHTTPRequest *)theRequest {

NSLog(@"registerFinished %@",[theRequest responseString]);

  }

  - (void)uploadFailed:(ASIHTTPRequest *)theRequest {

NSLog(@"registerFailed %@", [theRequest error]);

}

Upvotes: 1

Related Questions