当我尝试在Apple Watch上使用NSURLSession
使用POST调用Web服务时,响应参数为nil。这可能是什么问题?
调用网络服务的代码:
NSURL *url = [NSURL URLWithString:@"https://demo.test.com:22322/api/Alerts/UpdateAlertStatus?intUserId=5¶maccessTokenId=24460c5f-be71-45b5-99cf-f46c277c3d9e&UserId=100200"];
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
request.HTTPMethod = @"POST";
NSMutableDictionary *mutDictParameters = [[NSMutableDictionary alloc] init];
[mutDictParameters setObject:@"708" forKey:@"AlertId"];
[mutDictParameters setObject:@"2878" forKey:@"XmlMessageId"];
[mutDictParameters setObject:@"5" forKey:@"UserId"];
NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:mutDictParameters
options:kNilOptions error:&error];
if (!error) {
NSURLSessionUploadTask *uploadTask = [session uploadTaskWithRequest:request
fromData:data completionHandler:^(NSData *data,NSURLResponse *response,NSError *error) {
// Handle response here
NSLog(@"Response : %@",response);
}];
[uploadTask resume];
}