【发布时间】:2016-03-08 06:36:38
【问题描述】:
当我从 viewDidLoad 调用 getProfile 方法时
- (void)viewDidLoad {
[super viewDidLoad];
[self getProfile];
}
成功了
-(void)getProfile
{
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
NSString *tempurl= [NSString stringWithFormat:@"%@11155/person/@self",baseUrlSecure];
tempurl = [tempurl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:tempurl];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request addValue:gWCToken forHTTPHeaderField:@"WCToken"];
[request addValue:gWCTrustedToken forHTTPHeaderField:@"WCTrustedToken"];
[request setHTTPMethod:@"GET"];
NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error)
{
NSLog(@"Error: %@", error);
dispatch_async(dispatch_get_main_queue(), ^{
[Alert showAlertWithTitle:@"M2All" andWithMessage:error.localizedDescription onView:self andErrorCode:[NSString stringWithFormat:@"%ld",error.code]];
});
}
else
{
NSDictionary *dictResult = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSArray *arrError = [dictResult objectForKey:@"errors"];
if(arrError.count >0)
{
dispatch_async(dispatch_get_main_queue(), ^{
[Alert showAlertWithTitle:@"M2All" andWithMessage:[[arrError objectAtIndex:0] objectForKey:@"errorMessage"] onView:self andErrorCode:[[arrError objectAtIndex:0] objectForKey:@"errorCode"]];
});
return;
}
}
}];
[postDataTask resume];
}
但是来自 webViewDidFinishLoad 的相同调用然后得到错误
不知道是什么问题
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[self getProfile];
}
【问题讨论】:
-
你得到了什么错误..
-
errors = ( { errorCode = CWXFR0220E; errorKey = "ERR_COOKIE_TO_TOKEN_UID_MISMATCH"; errorMessage = "CWXFR0220E: 发生安全错误,因为 WCToken 中的用户 ID 74007 与 WC_USER_ACTIVITY 中的用户 ID -1002 不匹配cookie."; errorParameters = "[74007, -1002]"; } ); }
-
这不是一个常见的错误兄弟,请在后端检查一次
-
后端人员说您的请求没有到达服务器
-
他说谎,打印回声一次,