Search code examples
iosobjective-cafnetworkingdelete-row

How to delete collectionview records if encountered error 405?


I have a collection view and I would like to delete 1 of the records in the list. I use the code below when I click on a delete button:

NSString *wishlistID = @"5";
NSString *url_string = [NSString stringWithFormat: @"http://api.samplewebsite.com/api/product/wishlist_delete/%@",wishlistID];
[self.manager DELETE:url_string parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {

[self.collectionView reloadData];
}
failure:^(NSURLSessionDataTask *task, NSError *error) {

    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Please try again"
                                                                     message:[error localizedDescription]
                                                              preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok"
                                                       style:UIAlertActionStyleCancel
                                                     handler:nil];

    [alertVC addAction:okAction];

    [self presentViewController:alertVC animated:YES completion:nil];
}];

I hit the error as below:

Request failed: Method not allowed (405).

P.S.: Tested and able to delete records by using POSTMAN.


Solution

  • I solved my question by using codes as below in server end > web.config:-

    <system.webServer>
        <modules>
          <remove name="WebDAVModule" />
        </modules>
        <handlers>
          <remove name="WebDAV" /> 
        </handlers>
    </system.webServer>