We have developed a plugin that shares an account record with a team. we run the code shown below. we notice that the record is created in the POA table but the value of the
AccessRightsMask is 0.

we tested the same code in a console app and it works as expected, i.e. the AccessRightsMask has the expected value.
The plugin is configured with the calling user as a system admin, it is NOTin sandbox mode.
What are we leaving out or doing wrong?
GrantAccessRequest grantSharingRequest =
new
GrantAccessRequest()
{
PrincipalAccess
= new
PrincipalAccess()
{
AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.AppendAccess
Principal =
new
EntityReference("team",
teamId)
},
Target =
new
EntityReference("account",
AccountID)
};
GrantAccessResponse AccessResponse = (GrantAccessResponse)service.Execute(grantSharingRequest);