Objective c 带有setPostValue和方法DELETE的ASIFormDataRequest

Objective c 带有setPostValue和方法DELETE的ASIFormDataRequest,objective-c,json,cocoa-touch,asiformdatarequest,Objective C,Json,Cocoa Touch,Asiformdatarequest,我正在尝试将ASIFormDataRequest与SetPostValue和方法DELETE一起使用,下面是代码行 NSString *urlstring = [NSString stringWithFormat:@"%@%@",notificationsURL, typeId]; NSLog(@"Notification URL == %@",urlstring); NSURL *urlR = [NSURL URLWithString:urlstring]; notificationAPNR

我正在尝试将ASIFormDataRequest与SetPostValue和方法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];
在Success方法中,我得到代码405
NSLog(@“%d”,[request-responseStatusCode])


当我从邮递员客户那里打电话时,它就起作用了。请告诉我哪里出了错

当您对某些post参数使用DELETE方法时,您需要在设置Http DELETE方法之前调用“buildPostBody”函数,如下所示

[NotificationApnRequestSetPostValue:deviceId forKey:@“deviceId”]; [NotificationApnRequestSetPostValue:apnToken forKey:@“apnToken”]

[NotificationApnRequestBuildPostBody];///在设置请求方法之前调用此函数

[notificationAPNRequest setRequestMethod:@“删除”]


希望它现在可以工作

当您使用带有一些post参数的DELETE方法时,您需要在设置Http DELETE方法之前调用“buildPostBody”函数,如下所示

[NotificationApnRequestSetPostValue:deviceId forKey:@“deviceId”]; [NotificationApnRequestSetPostValue:apnToken forKey:@“apnToken”]

[NotificationApnRequestBuildPostBody];///在设置请求方法之前调用此函数

[notificationAPNRequest setRequestMethod:@“删除”]


希望它现在可以工作

一旦你可以打印[请求-响应字符串],并让我知道?@murali{“错误”:[“405方法不允许”]}@murali,但它可以从Chrome的邮递员那里工作。一旦你可以打印[请求-响应字符串],并让我知道?@murali{“错误”:[“405方法不允许”]@murali,但它可以从Chrome的邮递员那里工作。