Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

delete items from sharepoint list using oData REST API

$
0
0

I'm calling the REST API Service /listdata.svc to delete items from my list. When I hard code my parameter, it deletes, however, I need to pass the item to delete, when I do that it fails.

here is my code

   ContentItem item = dc.TrendingContent
                .Where(i => i.Id== id)
                .FirstOrDefault();
            dc.DeleteObject(item);
            dc.SaveChanges();

If I hardcode [id] it works, but the ID is going to be passed to the function. When I do that, then the error I get refers to

item = null

am I missing something or can the parameter not be passed to this call?

this works

ContentItem item = dc.TrendingContent
                .Where(i => i.Id== 12)
                .FirstOrDefault();
            dc.DeleteObject(item);
            dc.SaveChanges();

but the ID is going to be passed in


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>