SharePointVault ~/gotchas/graph ⌕ Search 459 pages, error messages, scripts…Ctrl K ★ Star
M↓ README.mdM↓ entra-policy-patch-replaces-complex-values-whole.md
sharepoint-vault›gotchas›graph›entra-policy-patch-replaces-complex-values-whole.mdhistoryedit on GitHub
● GOTCHAgraph· 3 min read

Updating Entra ID policy objects from Graph: some writes replace the whole value

applies to: Microsoft Graph v1.0 /groupSettings, /policies/deviceRegistrationPolicy, /directory/onPremisesSynchronization, /policies/identitySecurityDefaultsEnforcementPolicyreviewed: 2026-11-21#graph#entra-id#policies#patch#security-defaults#hybrid-identity

"Send only the field I change" is not how every Entra ID policy endpoint works. groupSettings requires the entire values collection, and deviceRegistrationPolicy is updated with PUT and a body with all updatable properties. For nested complex values (onPremisesSynchronization.features) the reference does not say whether a partial object is merged. Safe pattern for all of them: read the object, deep-copy the value, change one field, send the full copy back — and keep that read as the undo snapshot.

„Pošlu jen pole, které měním“ neplatí u všech endpointů zásad Entra ID. groupSettings vyžaduje celou kolekci values a deviceRegistrationPolicy se mění přes PUT s tělem obsahujícím všechny upravitelné vlastnosti. U vnořených komplexních hodnot (onPremisesSynchronization.features) dokumentace neříká, zda se částečný objekt sloučí. Bezpečný postup pro všechny: přečti objekt, zkopíruj hodnotu celou, změň jedno pole, pošli celou kopii zpět – přečtený stav si nech jako podklad pro vrácení.

Symptom

You flip one switch with a minimal body, the way the examples look:

PATCH https://graph.microsoft.com/v1.0/groupSettings/{id}
{ "values": [ { "name": "AllowToAddGuests", "value": "false" } ] }

The reference for this call says the opposite of what the example suggests: you must include the entire collection set; you cannot update a single set of values. A body with one pair is not a "change one setting" request.

Object What the reference says Safe body
/groupSettings/{id} values: "You must include the entire collection set." The whole values array you read, one value changed
/policies/deviceRegistrationPolicy PUT; supply the object "with all the updatable properties" (all marked Required) The whole object you read, minus read-only properties
/directory/onPremisesSynchronization/{id} PATCH; properties not in the body keep their values. Whether a partial features or configuration object is merged is not stated The whole features (or configuration) object you read, one flag changed

Fix

const cur = await graph.api(url).get();                    // also your undo snapshot
const features = JSON.parse(JSON.stringify(cur.features)); // full copy
features.blockSoftMatchEnabled = true;                     // change one field
await graph.api(url).patch({ features });                  // send the whole value
  • Re-read right before each write; if the object changed since you showed the plan, stop.
  • Undo = the same full-value write with the snapshot.
  • onPremisesSynchronization writes need OnPremDirectorySynchronization.ReadWrite.All and the signed-in user must be a Global Administrator (the only supported role).

Related trap: turning on security defaults

PATCH /policies/identitySecurityDefaultsEnforcementPolicy { "isEnabled": true }:

  • needs delegated Policy.Read.All and Policy.ReadWrite.ConditionalAccess (no narrower write permission exists) and at least the Conditional Access Administrator role;
  • is an either/or with Conditional Access: Microsoft says organizations that implement Conditional Access must disable security defaults — check for existing Conditional Access policies before you offer the switch;
  • since 29 July 2024 there is no 14-day registration grace: users without MFA must register when prompted at sign-in; legacy authentication and device code flow get blocked;
  • has no configurable exclusions — only directory synchronization accounts (Entra Connect / Cloud Sync) are skipped by Microsoft, so emergency access accounts need MFA too.

If your tool carries Policy.ReadWrite.ConditionalAccess only for this switch, add a build-time test that fails when any code path writes to /identity/conditionalAccess/... — the permission itself does not limit you to security defaults.

Sources

Was this helpful?ask or add your experience on GitHub →
Saved you an hour? A star on GitHub helps other SharePoint people find the vault.★ Star on GitHub
last reviewed: 2026-11-21last updated: 2026-11-21historyedit on GitHubview source