DeleteItemsUnconditional returns Error code 241

DeleteItemsUnconditional returns Error code 241

Anonymous
Not applicable
739 Views
2 Replies
Message 1 of 3

DeleteItemsUnconditional returns Error code 241

Anonymous
Not applicable

I'm trying to delete some items via the API and something is wrong. Could someone take a look at my code and help me out? Thanks

 

        public void DeleteItemsUnconditionally(ADSK.File _file)
        {
            // Set a reference to the items for the provided file.
            ADSK.Item[] _items = GetItemsFromFile(_file);

            // Return if no items exist.
            if (_items.Length == 0) return;

            // Set a reference to the item master id's
            List<long> _itemMstrIds = _items.Select(_item => _item.MasterId).ToList();

            // Set a reference to the items title.
            string _title = _items[0].Title;

            // Delete the items.
            try
            {
                ServiceManager.ItemService.DeleteItemsUnconditional(_itemMstrIds.ToArray());
                UpdateLog("","Item Deleted: " + _title);
            }
            catch (Exception)
            {   UpdateLog("","Item Delete Failure: " + _title,"Warning");}            
        }

        public ADSK.Item[] GetItemsFromFile(ADSK.File _file)
        {
            return ServiceManager.ItemService.GetItemsByFileId(_file.Id);
        }
0 Likes
Accepted solutions (1)
740 Views
2 Replies
Replies (2)
Message 2 of 3

wayne.brill
Collaborator
Collaborator

Hi Eric,

 

I used your code and it is deleting the items and I am not getting the 241 error. (I did have to use my own code to get the file to use and the WebServiceManager).

 

It may help to provide a minimal buildable project for me to test with.  Also what version of Vault are you using? Do you get any warnings deleting those items using Vault Explorer?

 

Thanks,

Wayne

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution
Yeah, I was procrastinating on updating my API reference from 2013 to 2015. That was the problem, certain parts of the 2013 API don’t seem to work with 2015. Thank you.
0 Likes