我正在尝试将 ASIFormDataRequest 与 setPostValues 和方法 DELETE 一起使用,以下是代码行
NSString *urlstring = [NSString stringWithFormat:@"%@%@",notificationsURL, typeId];
NSLog(@"Notification URL == %@",urlstring);
NSURL *urlR = [NSURL URLWithString:urlstring];
notificationAPNRequest = [ASIFormDataRequest requestWithURL:urlR];
notificationAPNRequest.timeOutSeconds = 30;
notificationAPNRequest.useSessionPersistence = NO;
[notificationAPNRequest setPostValue:deviceId forKey:@"deviceId"];
[notificationAPNRequest setPostValue:apnToken forKey:@"apnToken"];
if ([methodStr isEqualToString:@"OFF"]) {
[notificationAPNRequest setRequestMethod:@"DELETE"];
}
else if ([methodStr isEqualToString:@"ON"]) {
[notificationAPNRequest setRequestMethod:@"PUT"];
}
[notificationAPNRequest setDelegate:self];
[notificationAPNRequest setDidFinishSelector:@selector(notificationAPNSuccess:)];
[notificationAPNRequest setDidFailSelector:@selector(notificationAPNFailure:)];
[notificationAPNRequest startAsynchronous];
在成功方法中,我得到代码 405
NSLog(@"%d",[request responseStatusCode]);
当我从邮递员客户那里打到它时,它就起作用了。请让我知道我在哪里做错了。