We are using the Power Automate Web API by connecting to "https://*****.crm.dynamics.com/" ( where ***** is the environment URL or instance of CDS) using the token generated using MSAL ( by using the client ID of our custom registered app). We are performing a POST, DELETE and PATCH request but are receiving an Error 400 - Bad Request when trying to activate the power automate flow on using PATCH( i.e. when statecode = 1). The flow gets created just fine but cannot turn it on. We assume this is because the service principal or our application user is not a licensed user in Dataverse/CDS.

Please let me know if its possible to add an application as a licensed user for Dataverse? i.e. to assign a license to an object ID/service principal? Main goal is to be able to turn on the flow in CDS with the service principal id of our custom API.  

Here are some more details:

1. An app registration for our custom API exists in Azure 

2. Our custom API is present under ' Application users' in the Dataverse

3. Security roles have been assigned ( also assigned system administrator role)

4. Added this service principal to a security group and added in 'Power Apps and Flow' enterprise application group

5. Assigned the following licenses to the security group mentioned in step 4. 


Any help is greatly appreciated. Thank you in advance.