Hi
I need to create a solution, dataverse and app and customizations using PowerShell and Rest API
I am using this information:
Create, manage, and publish model-driven apps using code - Power Apps | Microsoft Learn
However, I am getting a 401 not authorized error message, so this information is not complete as it doesn't mention anything about security. Is there a published reference of the various APIs that can be used to create model-driven apps using REST and PowerShell
$token = '0000000-0000-000000000-1-000000'
$url = 'https://dev.api.crm3.dynamics.com/api/data/v9.2'
$method = 'POST'
$headers = @{
'Content-Type'='application/json'
'Authorization'='Bearer $token'
'charset'='utf-8'
'OData-MaxVersion'='4.0'
'OData-version'='4.0'
'Accept'='application/json'
}
$body = @{
"name"="App20"
"uniquename"="App20"
"webresourceid"="953b9fac-1e5e-e611-80d6-00155ded156f"
}
Invoke-RestMethod -Method $method -Uri $url -Body($body|ConvertTo-Json) -Headers $headers -ContentType "application/json"
Yes thanks, I finally figured out. I'm actually using a combination of PowerShell and pac cli which does the job nicely and it is easily integrated into Azure DevOps.
Hi @kevlangdoc,
Did you manage to get this working? You'll need to authenticate and get the token before the rest request. Furthermore, whoever you authenticate with will need to have the rights privileges via security roles to create/manage Dataverse solutions. So for instance, if you're authenticating with yourself, you should have "System Administrator" role assigned to you and then you can authenti
If you're using PowerShell then you can use the PAC cmdlets (Power Platform CLI) to simplify the code and work with solutions. Here's an example:
# authenticate and can also use a SPN
pac auth create --url https://myorg.crm.dynamics.com
# create solution
pac solution init --publisher-name developer --publisher-prefix dev
# or base on an existing solution
pac solution clone --name sampleSolution
# add component to a solution
pac solution add-solution-component --component 00000000-0000-0000-0000-000000000000 --componentType 1 --solutionUniqueName sampleSolution
More on PAC: https://learn.microsoft.com/en-us/power-platform/developer/cli/introduction#common-commands
Hope this helps!
Hello @kevlangdoc,
You can find information about authentication in the documentation for the Web API.
If you want to improve the documentation in the link you posted: The documentation is provided by Microsoft, and you can leave feedback at the end of the page.
Michael E. Gernaey
15
Super User 2025 Season 1
stampcoin
9
bscarlavai33
5
Super User 2025 Season 1