Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use un permiso o permisos con privilegios superiores solo si la aplicación lo requiere. Para obtener más información sobre los permisos delegados y de aplicación, consulte Tipos de permisos. Para obtener más información sobre estos permisos, consulte la referencia de permisos.
Colección de objetos mailboxProtectionUnit que se van a agregar o quitar de la directiva de protección de Exchange. Obligatorio.
Para quitar un mailboxProtectionUnit de la directiva, especifique la @removed anotación en el cuerpo de la solicitud para la unidad de protección junto con el identificador del mailboxProtectionUnit.
Respuesta
Si se ejecuta correctamente, este método devuelve un 200 OK código de respuesta y un objeto exchangeProtectionPolicy actualizado en el cuerpo de la respuesta.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
using Microsoft.Kiota.Abstractions.Serialization;
var requestBody = new ExchangeProtectionPolicy
{
DisplayName = "Exchange Policy - Inadvertent data loss",
AdditionalData = new Dictionary<string, object>
{
{
"mailboxProtectionUnits@delta" , new List<object>
{
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"directoryObjectId", new UntypedString("1b014d8c-71fe-4d00-a01a-31850bc5b32c")
},
}),
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"directoryObjectId", new UntypedString("2b014d8c-71fe-4d00-a01a-31850bc5b32c")
},
}),
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"@removed", new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"reason", new UntypedString("changed")
},
})
},
{
"id", new UntypedString("99954f18-c8ec-4b62-85bf-cdf3b70b140e")
},
}),
new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"@removed", new UntypedObject(new Dictionary<string, UntypedNode>
{
{
"reason", new UntypedString("changed")
},
})
},
{
"id", new UntypedString("4267e382-71a9-4c07-bef7-bda97e09c0d2")
},
}),
}
},
},
};
// 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.ExchangeProtectionPolicies["{exchangeProtectionPolicy-id}"].PatchAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Authorization", "Bearer <Access-Token>");
});
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ExchangeProtectionPolicy exchangeProtectionPolicy = new ExchangeProtectionPolicy();
exchangeProtectionPolicy.setDisplayName("Exchange Policy - Inadvertent data loss");
HashMap<String, Object> additionalData = new HashMap<String, Object>();
LinkedList<Object> mailboxProtectionUnitsDelta = new LinkedList<Object>();
property = new ();
property.setDirectoryObjectId("1b014d8c-71fe-4d00-a01a-31850bc5b32c");
mailboxProtectionUnitsDelta.add(property);
property1 = new ();
property1.setDirectoryObjectId("2b014d8c-71fe-4d00-a01a-31850bc5b32c");
mailboxProtectionUnitsDelta.add(property1);
property2 = new ();
removed = new ();
removed.setReason("changed");
property2.setRemoved(removed);
property2.setId("99954f18-c8ec-4b62-85bf-cdf3b70b140e");
mailboxProtectionUnitsDelta.add(property2);
property3 = new ();
removed1 = new ();
removed1.setReason("changed");
property3.setRemoved(removed1);
property3.setId("4267e382-71a9-4c07-bef7-bda97e09c0d2");
mailboxProtectionUnitsDelta.add(property3);
additionalData.put("mailboxProtectionUnits@delta", mailboxProtectionUnitsDelta);
exchangeProtectionPolicy.setAdditionalData(additionalData);
ExchangeProtectionPolicy result = graphClient.solutions().backupRestore().exchangeProtectionPolicies().byExchangeProtectionPolicyId("{exchangeProtectionPolicy-id}").patch(exchangeProtectionPolicy, requestConfiguration -> {
requestConfiguration.headers.add("Authorization", "Bearer <Access-Token>");
});