microsoft / PowerPlatform-DataverseServiceClient

Code Replica for Microsoft.PowerPlatform.Dataverse.Client and supporting nuget packages.
MIT License
284 stars 52 forks source link

Unable to Write to Virtual Tables in Dataverse Connected to Business Central #472

Open alwill opened 1 month ago

alwill commented 1 month ago

Description: We are attempting to programmatically write data to the Customer and Company virtual tables that are connected to Business Central. These virtual tables reside in Dataverse and function correctly when accessed directly through the PowerApps portal at https://make.powerapps.com/.

However, when using our connection string in the C# application to connect to Dataverse, we are unable to write to these virtual tables.

Notably: We can write data to other Dataverse tables. We cannot write to the virtual tables associated with Business Central. It seems that the authentication token generated by ServiceClient might not be receiving the necessary scope to write to Business Central tables.

What We've Tried: We verified that the Azure App Registration has appropriate API permissions for both Dynamics 365 and Business Central. The issue appears to be specific to virtual tables, as other Dataverse tables are not affected.

Error: Message: Microsoft.OData.Client.DataServiceQueryException: An error occurred while processing this request. ---> Microsoft.OData.Client.DataServiceClientException: {"error":{"code":"Authentication_InvalidCredentials","message":"The server has rejected the client credentials. }} ---> Microsoft.OData.ODataErrorException: An error was read from the payload. See the 'Error' property for more details.

Question: Is this behavior expected? Does ServiceClient support writing to virtual tables connected to Business Central, or are additional configuration steps needed for the token to include the required scope?

MattB-msft commented 1 month ago

@alwill

Are you using a User Interactive flow to create the connection? or are using a non-interactive flow to create the connection? Most Virtual Tables to other Dynamics Products require User Tokens and will not work with Service Principal tokens.