-1

I have created Items using Item Web API. Now I want to get the unused items on my site. So I'm trying to get the item references using Item Web API.

var referrers = Globals.LinkDatabase.GetReferrers(item);

            if (referrers == null || !referrers.Any() || referrers.All(x => x.GetSourceItem() == null))
            {
                // 4. Delete item
                item.Delete();
            }

How I achieve this(in C# code) using Item Web API / Sitecore.services.client Item web service or Is there any other way to get the unused items please let me know. ?

Also can any one please explain which one is powerful(Item Web API/ Sitecore.services.client)?

0
1

It is not supported.

They both are used only for accessing items content, CRUD operations over an item and items searching.

You can find full API overview in official developer guides:

Sitecore Service Client

Item Web API

0

Perhaps you can start with an article like this on how to implement a WebApi service: https://laubplusco.net/implementing-webapi-service-using-servicesapicontroller-sitecore-8/

Then you can simplify your code to just check the referrer count.

// item is passed in through a method

var linkDb = Globals.LinkDatabase;
if (linkDb.GetReferrerCount(item) <= 0) {
    item.Delete();
}
1
  • Thanks. This is not the answer I'm looking for. I'm trying to implement the same in Item web API or Sitecore.services.client.
    – Rajasekar
    Apr 27 '20 at 2:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.