Erstellen Sie eine Schutzrichtlinie für einen M365-Dienst SharePoint. Die Richtlinie wird im inactive Zustand erstellt. Der Benutzer kann auch eine Liste der Schutzeinheiten unter der Richtlinie angeben.
Wählen Sie für diese API die Als am wenigsten privilegierten Berechtigungen gekennzeichneten Berechtigungen aus. Verwenden Sie nur dann eine Berechtigung mit höheren Berechtigungen , wenn dies für Ihre App erforderlich ist. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
Berechtigungstyp
Berechtigungen mit den geringsten Berechtigungen
Berechtigungen mit höheren Berechtigungen
Delegiert (Geschäfts-, Schul- oder Unikonto)
BackupRestore-Configuration.ReadWrite.All
Nicht verfügbar.
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Nicht unterstützt
Anwendung
BackupRestore-Configuration.ReadWrite.All
Nicht verfügbar.
HTTP-Anforderung
POST /solutions/backupRestore/sharePointProtectionPolicies/
Auflistung der siteProtectionUnits, die dem sharePointProtectionPolicy-Objekt hinzugefügt werden soll. Erforderlich. Das Format von siteId finden Sie unter siteId .
Antwort
Bei erfolgreicher Ausführung gibt die Methode einen 201 Created Antwortcode und ein sharePointProtectionPolicy-Objekt im Antworttext zurück.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new SharePointProtectionPolicy
{
DisplayName = "SharePoint Protection Policy",
SiteProtectionUnits = new List<SiteProtectionUnit>
{
new SiteProtectionUnit
{
SiteId = "contoso.sharepoint.com,febad3c2-a7b2-454c-8910-272c7bcf78fc,ba7b70d0-8ba0-4cae-b19a-7cb8c739512f",
},
new SiteProtectionUnit
{
SiteId = "contoso.sharepoint.com/sites/marketing,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740",
},
new SiteProtectionUnit
{
SiteId = "contoso.sharepoint.com/sites/hr,3bfc861e-9a17-4a27-9562-3d8b26c81bb5,0271110f-634f-4300-a841-3a8a2e851851",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Solutions.BackupRestore.SharePointProtectionPolicies.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SharePointProtectionPolicy sharePointProtectionPolicy = new SharePointProtectionPolicy();
sharePointProtectionPolicy.setDisplayName("SharePoint Protection Policy");
LinkedList<SiteProtectionUnit> siteProtectionUnits = new LinkedList<SiteProtectionUnit>();
SiteProtectionUnit siteProtectionUnit = new SiteProtectionUnit();
siteProtectionUnit.setSiteId("contoso.sharepoint.com,febad3c2-a7b2-454c-8910-272c7bcf78fc,ba7b70d0-8ba0-4cae-b19a-7cb8c739512f");
siteProtectionUnits.add(siteProtectionUnit);
SiteProtectionUnit siteProtectionUnit1 = new SiteProtectionUnit();
siteProtectionUnit1.setSiteId("contoso.sharepoint.com/sites/marketing,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740");
siteProtectionUnits.add(siteProtectionUnit1);
SiteProtectionUnit siteProtectionUnit2 = new SiteProtectionUnit();
siteProtectionUnit2.setSiteId("contoso.sharepoint.com/sites/hr,3bfc861e-9a17-4a27-9562-3d8b26c81bb5,0271110f-634f-4300-a841-3a8a2e851851");
siteProtectionUnits.add(siteProtectionUnit2);
sharePointProtectionPolicy.setSiteProtectionUnits(siteProtectionUnits);
SharePointProtectionPolicy result = graphClient.solutions().backupRestore().sharePointProtectionPolicies().post(sharePointProtectionPolicy);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.share_point_protection_policy import SharePointProtectionPolicy
from msgraph.generated.models.site_protection_unit import SiteProtectionUnit
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SharePointProtectionPolicy(
display_name = "SharePoint Protection Policy",
site_protection_units = [
SiteProtectionUnit(
site_id = "contoso.sharepoint.com,febad3c2-a7b2-454c-8910-272c7bcf78fc,ba7b70d0-8ba0-4cae-b19a-7cb8c739512f",
),
SiteProtectionUnit(
site_id = "contoso.sharepoint.com/sites/marketing,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740",
),
SiteProtectionUnit(
site_id = "contoso.sharepoint.com/sites/hr,3bfc861e-9a17-4a27-9562-3d8b26c81bb5,0271110f-634f-4300-a841-3a8a2e851851",
),
],
)
result = await graph_client.solutions.backup_restore.share_point_protection_policies.post(request_body)