Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
dver344
Frequent Visitor

Microsoft Fabric API: 400 Bad Request

Hi guys!

 

Does anyone have more experience with the Microsoft Fabric API? I'm currently facing the issue that, when I try to reproduce an endpoint in Powershell, (e.g. https://learn.microsoft.com/en-us/rest/api/fabric/lakehouse/items/list-lakehouses?tabs=HTTP), I almost always get a 400 Bad request. I currently only got the 'List all workspaces' to work, but I'm kinda stuck after this.

 

I'm asking since I know that the Fabric API is for a lot of endpoints still in preview.

Update: https://learn.microsoft.com/en-us/rest/api/fabric/core/items/list-items?tabs=HTTP seems to work to list all the possible items inside of your workspace, but then you have to filter yourself. While the list-lakehouses endpoint should return all possible lakehouses.

 

Thanks!

1 ACCEPTED SOLUTION
kur83
Frequent Visitor

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.

kur83_0-1724878706986.png

 

It's solved in this article: Solved: Re: Need help to create Lakehouse programmatically... - Microsoft Fabric Community

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @dver344 ,

Base on your description, it seems like you got 400 bad request error when call Fabric API Items - List LakehousesA 400 Bad Request error typically indicates that the server cannot process the request due to client-side issues. Did you get the required permission and scope?

vyiruanmsft_1-1721371184374.png

As I tested in my side, it can return the expected result...

vyiruanmsft_2-1721371380918.png

vyiruanmsft_3-1721371464071.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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:

{
    "requestId": "XXX",
    "errorCode": "InsufficientScopes",
    "message": "The caller does not have sufficient scopes to perform this operation"
}

 

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!

Can you help me with the powershell script. I tried, to get token from browser, n copy in script, but still it's 400 bad request error. I can get pipeline definition using same token, but creating any item using definition file I am receiving this error. Not much sure on how to use.platform and either items like.py or pipeline.json build definition file, and create item in fabric. Need help in creating items such as notebook, pipeline etc in fabric using powershell rest api. I have all my fikes in azure repo. With each file having.platform and json or .py files . kindly help

kur83
Frequent Visitor

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.

kur83_0-1724878706986.png

 

It's solved in this article: Solved: Re: Need help to create Lakehouse programmatically... - Microsoft Fabric Community

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.