NSMutableDictionary *dic=[NSMutableDictionary dictionary];
[dic setValue:@"Abdul Kareem" forKeyPath:@"user_name"];
[dic setValue:@"signup" forKeyPath:@"action"];
[dic setValue:@"a.kareem.tn@gmail.com" forKeyPath:@"email"];
[dic setValue:@"abc" forKeyPath:@"password"];
[dic setValue:@"28" forKeyPath:@"age"];
[dic setValue:@"Male" forKeyPath:@"gender"];
[dic setValue:@"80" forKeyPath:@"weight"];
[dic setValue:@"6" forKeyPath:@"height"];
NSString *jsonRequest = [dic JSONRepresentation];
jsonRequest =[jsonRequest stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",SERVIEC_URL,jsonRequest]];
ASIFormDataRequest *request =[ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request addRequestHeader:@"User-Agent" value:@"ASIHTTPRequest"];
[request addRequestHeader:@"Content-Type" value:@"application/json"];
//[request appendPostData:[jsonRequest dataUsingEncoding:NSUTF8StringEncoding]];
if (imageData != nil) { ///for image data
[request setData:imageData withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:@"picture"];
}
[request setDelegate:self];
[request setShowAccurateProgress:YES];
[request setUsername:"user name if you have on webservice"];
[request setPassword:"password if you have on webservice"];
[request startAsynchronous];
No comments:
Post a Comment