.netazuremicrosoft-graph-apio365security-compliance

Is there a way to get the statistics of data in legal hold through graph API?


I am currently working on eDiscovery Reference through graph API and I want to know if there is a way of getting statistics of data that is put on legal hold

Attached an image below and the statistics I am looking for (image is from compliance.microsoft.com)

enter image description here

Can we get the statistics from below through any graph API ?


Solution

  • If you know legalHold id you can use the ID of legalHold resource for the eDiscovery case.

    You can call

    GET /compliance/ediscovery/cases/{caseId}/sourceCollections
    
    var sourceCollections = await graphClient.Compliance.Ediscovery.Cases["{ediscovery.case-id}"].SourceCollections
        .Request()
        .GetAsync();
    

    to get list of sourceCollection.

    For each sourceCollection you can run an estimate of the number of emails and documents in the source collection

    POST /compliance/ediscovery/cases/{caseId}/sourceCollections/{sourceCollectionId}/estimateStatistics
    
    await graphClient.Compliance.Ediscovery.Cases["{caseId}"].SourceCollections["{sourceCollectionId}"]
    .EstimateStatistics()
    .Request()
    .PostAsync();
    

    The response will contain a Location header, which contains the location of the estimateStatisticsOperation that was created to handle the estimate.

    Or you can get the last estimateStatisticsOperation object associated with a source collection.

    GET /compliance/ediscovery/cases/{caseId}/sourceCollections/{sourceCollectionId}/lastEstimateStatisticsOperation
    
    var estimateStatisticsOperation = await graphClient.Compliance.Ediscovery.Cases["{caseId}"].SourceCollections["{sourceCollectionId}"].LastEstimateStatisticsOperation
    .Request()
    .GetAsync();
    

    estimateStatisticsOperation contains the properties status, siteCount, mailboxCount, indexedItemCount, indexedItemsSize, unindexedItemCount and unindexedItemsSize.