I am trying to do the same thing via power automate using graph and struck the same wall.
I can get the policy fine via GET https://graph.microsoft.com/v1.0/policies/homeRealmDiscoveryPolicies/<policyid>
But when trying to update it with PATCH following the instruction in.
https://learn.microsoft.com/en-us/graph/api/homerealmdiscoverypolicy-update?view=graph-rest-1.0&tabs=http
I get Forbidden - 403 with the message "Insufficient privileges to complete the operation."
The app registration used in the call has the permission Policy.ReadWrite.ApplicationConfiguration.
I have also tried to temporarily give all ReadWrite permissions I could find in graph but still got the same error.
I also tried to create a new policy supplying the response from when getting the current policy
{
"definition": [
"{\"B2BManagementPolicy\":{\"InvitationsAllowedAndBlockedDomainsPolicy\":{\"AllowedDomains\":[\"atea.se\",\"gmail.com\"]},\"AutoRedeemPolicy\":{\"AdminConsentedForUsersIntoTenantIds\":[],\"NoAADConsentForUsersFromTenantsIds\":[]}}}"
],
"displayName": "B2BManagementPolicy",
"type": "B2BManagementPolicy",
"isOrganizationDefault": true
}
I have tried both with and without the property "type" and that runs without error, but it creates a policy with the type "HomeRealmDiscoveryPolicy" that doesn't seem to do anything. On that policy it does work to use PATCH to update it.
Is it just not possible to update the B2BManagementPolicy via graph yet?