Forum Discussion
Microsoft Fabric API: 400 Bad Request
- 1 year ago
You can create a lakehouse and other items using Service Principal. Please make sure below settings are enabled for Service Principal. Make sure Allow Service Principals to create and use Profiles enabled.
It's solved in this article: Solved: Re: Need help to create Lakehouse programmatically... - Microsoft Fabric Community
Hi there!
Thanks for the response. I figured out the issue by looking closer at the response body:
Response body: {"requestId":"XXX","errorCode":"PrincipalTypeNotSupported","message":"The operation is not supported for the principal type"}
So basically, I've been using a service principal as suggested in the quickstart guide. I've been able to load lists of workspaces, items, ... and have already been able to create some cool powershell scripts with it. However, I'm unable to create items (lakehouses, notebooks, ...) dynamically due to this limitation. If I want to generate a token, I always need to use 'copy(powerBIAccessToken)' inside of the dev-tools in my browser itself.
The general Powershell functions to generate a new token via 'Get-PowerBIAccessToken' inside a powershell script doesn't seem to work. It states that if I do it via that way, I have insufficient permissions:
If I do it in the browser via 'copy(...)', and use that bearer token in my request, it will work and creates items, ...
Is there some news on this front as well? Why there is a difference between copy() via the DevTools in the browser compared to using the Get-PowerBIAccessToken inside your Powershell script? I'm logging in with the same user each time, so it shouldn't matter much.
Thanks!
You can create a lakehouse and other items using Service Principal. Please make sure below settings are enabled for Service Principal. Make sure Allow Service Principals to create and use Profiles enabled.
It's solved in this article: Solved: Re: Need help to create Lakehouse programmatically... - Microsoft Fabric Community