Below is my POST request example which saves Employee details. This work fine and I'm sending individual employee details.
But what if I have to save more then one Employee details...do I have to call below method those many time's ... How can I send all data in individual object like nsmutablearray of nsmutable dictionary....
-(void)saveEmployDetails
{
NSString * strBody = @"Employee=1&Class=tes&Comp=test&Type=Fixed";
NSString *strUrl = [[NSString alloc] initWithFormat:@"%@/api/external/SaveEmployee?type=%@", strCompURL, strType];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:strUrl]];
request.HTTPMethod = @"POST";
request.HTTPBody = [strBody dataUsingEncoding:NSUTF8StringEncoding];
request.timeoutInterval = 5;
NSURLSessionDataTask *task = [sessionMnger dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
if (!error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if (httpResponse.statusCode == 200)
{
NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers|NSJSONReadingAllowFragments error:nil];
NSLog(@"data:%@", jsonData);
}
}
else
NSLog(@"Error:%@", error.description);
}];
[task resume];
}
Webservice Team gave me body for above API POST call like
This is a Post Method and below is the Body Object
[
{
"Employee":937,
"Class":test,
"Comp":test,
"Type":test
}
]
How to send more then one employee details together in above API
replace you string body
NSString * strBody = @"Employee = 1 & Class = tes & Comp = test & Type = Fixed"
to