The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Is there a way to update by powershell & Rest Api the default lakehouse of a notebook?
I tried to update it by
$payload = @{
kernel_info = @{
name = "synapse_pyspark"
}
dependencies = @{
lakehouse = @{
default_lakehouse = $lakehouseId
default_lakehouse_name = $lakehouseName
default_lakehouse_workspace_id = $workspaceId
}
}
} | ConvertTo-Json -Depth 10
# convert this payload to base64
$payloadBase64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($payload))
and
# Construct the request body
$body = @{
definition = @{
parts = @(
@{
path = ".platform"
payload= $payloadBase64
payloadType= "InlineBase64"
}
)
}
} | ConvertTo-Json -Depth 10
but that gives me the error:
{
"requestId": "a4057ddd-bc63-4b2c-a620-5a22ceb206b8",
"errorCode": "InvalidDefinitionParts",
"moreDetails": [
{
"errorCode": "InvalidPlatformFile",
"message": "Invalid platform file"
}
],
"message": "One or more definition parts missing or invalid"
}
I do not see what I am doing wrong
Somebidy have some experience?
thanks
Wijnand
Solved! Go to Solution.
I found the solution myself.
The problem was that the payload of the update request requires a .py file and not an ipynb file format.
So by contructing an .py file like :
# Fabric notebook source
# METADATA ********************
# META {
# META "kernel_info": {
# META "name": "synapse_pyspark"
# META },
# META "dependencies": {
# META "lakehouse": {
# META "default_lakehouse": "14ba2f96-9077-4ea9-895a-73d6d9251ca1",
# META "default_lakehouse_name": "lh_silver_colorpremium",
# META "default_lakehouse_workspace_id": "baa1eb69-b324-433e-aa10-4bbf988965a8"
# META }
# META }
# META }
# MARKDOWN ********************
# ### Import Utilities
# CELL ********************
%run nb-notebook-utilities
# METADATA ********************
# META {
# META "language": "python",
# META "language_group": "synapse_pyspark"
# META }
It works.
Thank you all for the support! Solved
Wijnand
hi @wbeke , May i know if you have had the chance to try my suggestions. If you did, can you please share the results. Thank you.
Hi @wbeke , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.
try this too:
The API expects `updateMetadata=True` as a query parameter (in the URL), not as a body field. Remove `"updateRequest": true` from your JSON.
The `displayName`, `description`, and `type` fields belong to the item’s metadata, not the `updateDefinition` API. This endpoint only accepts a `definition` object.
Sorry, still no luck.
url is now without the updateMetadat=True, because I do not want to update the patform.
the body is:
{
"definition": {
"parts": [
{
"payloadType": "InlineBase64",
"path": "notebook-content.ipynb",
"payload": "ew0KICAgICJjZWxscyI6ICBbDQogICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgImNlbGxfdHlwZSI6ICAiY29kZSIsDQogICAgICAgICAgICAgICAgICAgICAgInNvdXJjZSI6ICBbDQoNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF0sDQogICAgICAgICAgICAgICAgICAgICAgIm91dHB1dHMiOiAgWw0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXSwNCiAgICAgICAgICAgICAgICAgICAgICAiZXhlY3V0aW9uX2NvdW50IjogIG51bGwsDQogICAgICAgICAgICAgICAgICAgICAgIm1ldGFkYXRhIjogIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJtaWNyb3NvZnQiOiAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImxhbmd1YWdlIjogICJweXRob24iLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImxhbmd1YWdlX2dyb3VwIjogICJzeW5hcHNlX3B5c3BhcmsiDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiY2VsbFN0YXR1cyI6ICAie1wiV2lqbmFuZCBCZWtlXCI6e1wic2Vzc2lvbl9zdGFydF90aW1lXCI6bnVsbCxcImV4ZWN1dGlvbl9zdGFydF90aW1lXCI6XCIyMDI1LTA0LTI0VDEzOjQ3OjUyLjg5NjM1MjFaXCIsXCJleGVjdXRpb25fZmluaXNoX3RpbWVcIjpcIjIwMjUtMDQtMjRUMTM6NDc6NTMuMjI5MzIxM1pcIixcInN0YXRlXCI6XCJmaW5pc2hlZFwiLFwibGl2eV9zdGF0ZW1lbnRfc3RhdGVcIjpcImF2YWlsYWJsZVwiLFwibm9ybWFsaXplZF9zdGF0ZVwiOlwiZmluaXNoZWRcIn19IiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJlZGl0YWJsZSI6ICB0cnVlLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInJ1bl9jb250cm9sIjogIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImZyb3plbiI6ICBmYWxzZQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwNCiAgICAgICAgICAgICAgICAgICAgICAiaWQiOiAgIjg1MDZhNDBjLTVkNGEtNDFlNy04YTE4LTVhYzE2NjRiZGI1MCINCiAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgXSwNCiAgICAibWV0YWRhdGEiOiAgew0KICAgICAgICAgICAgICAgICAgICAgImxhbmd1YWdlX2luZm8iOiAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJuYW1lIjogICJweXRob24iDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LA0KICAgICAgICAgICAgICAgICAgICAgImtlcm5lbHNwZWMiOiAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJuYW1lIjogICJzeW5hcHNlX3B5c3BhcmsiLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJsYW5ndWFnZSI6ICAiUHl0aG9uIiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZGlzcGxheV9uYW1lIjogICJTeW5hcHNlIFB5U3BhcmsiDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LA0KICAgICAgICAgICAgICAgICAgICAgImtlcm5lbF9pbmZvIjogIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIm5hbWUiOiAgInN5bmFwc2VfcHlzcGFyayINCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LA0KICAgICAgICAgICAgICAgICAgICAgIm1pY3Jvc29mdCI6ICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibGFuZ3VhZ2UiOiAgInB5dGhvbiIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibGFuZ3VhZ2VfZ3JvdXAiOiAgInN5bmFwc2VfcHlzcGFyayIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibXNfc3BlbGxfY2hlY2siOiAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibXNfc3BlbGxfY2hlY2tfbGFuZ3VhZ2UiOiAgImVuIg0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwNCiAgICAgICAgICAgICAgICAgICAgICJudGVyYWN0IjogIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAidmVyc2lvbiI6ICAibnRlcmFjdC1mcm9udC1lbmRAMS4wLjAiDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LA0KICAgICAgICAgICAgICAgICAgICAgInNwYXJrX2NvbXB1dGUiOiAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJjb21wdXRlX2lkIjogICIvdHJpZGVudC9kZWZhdWx0IiwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAic2Vzc2lvbl9vcHRpb25zIjogIHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiY29uZiI6ICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJzcGFyay5zeW5hcHNlLm5icy5zZXNzaW9uLnRpbWVvdXQiOiAgIjEyMDAwMDAiDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwNCiAgICAgICAgICAgICAgICAgICAgICJkZXBlbmRlbmNpZXMiOiAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImxha2Vob3VzZSI6ICB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZGVmYXVsdF9sYWtlaG91c2VfbmFtZSI6ICAibGhfZF90ZXN0X2Zvcl9yZXN0X2FwaSIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZGVmYXVsdF9sYWtlaG91c2UiOiAgIjEyNTBmMDFhLTc3ZDctNDhkOS1hODI0LTlkZjQ2ODFmZDdmYSIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZGVmYXVsdF9sYWtlaG91c2Vfd29ya3NwYWNlX2lkIjogICI5YWMyZWFkMS0wNzFhLTRiNjEtYWQ0NC02MWYwOTA1NWI0MGYiDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZW52aXJvbm1lbnQiOiAgew0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgIH0sDQogICAgIm5iZm9ybWF0IjogIDQsDQogICAgIm5iZm9ybWF0X21pbm9yIjogIDUNCn0="
}
]
}
}
This is a long LRO call so check the reposnse of the rest api call (seems to be ok)
{
"Headers": {
"Pragma": "no-cache",
"Transfer-Encoding": "chunked",
"Retry-After": "20",
"x-ms-operation-id": "1a351fe7-bad7-496d-9abe-d3d1c57896d6",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"RequestId": "6274790f-d7e6-4c75-ae03-7a1bb1c92fd2",
"Access-Control-Expose-Headers": "RequestId,Location,Retry-After,x-ms-operation-id",
"request-redirected": "true",
"home-cluster-uri": "https://wabi-north-europe-f-primary-redirect.analysis.windows.net/",
"Cache-Control": "no-store, must-revalidate, no-cache",
"Content-Type": "application/json; charset=utf-8",
"Date": "Tue, 06 May 2025 16:08:10 GMT",
"Location": "https://wabi-north-europe-f-primary-redirect.analysis.windows.net/v1/operations/1a351fe7-bad7-496d-9abe-d3d1c57896d6"
}
}
But then checking the location (added with /result) I do get an error:
Location: https://wabi-north-europe-f-primary-redirect.analysis.windows.net/v1/operations/1a351fe7-bad7-496d-9...
Retrying after 20 seconds...
Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
At C:\Temp\Fabric CLI private preview\mytests\fabric.ps1:478 char:21
+ ... $response = Invoke-WebRequest $url -Headers $fabricHeaders -Method Ge ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
The default lakehouse is not updated
Maybe you see something I miss
Wijnand
I found the solution myself.
The problem was that the payload of the update request requires a .py file and not an ipynb file format.
So by contructing an .py file like :
# Fabric notebook source
# METADATA ********************
# META {
# META "kernel_info": {
# META "name": "synapse_pyspark"
# META },
# META "dependencies": {
# META "lakehouse": {
# META "default_lakehouse": "14ba2f96-9077-4ea9-895a-73d6d9251ca1",
# META "default_lakehouse_name": "lh_silver_colorpremium",
# META "default_lakehouse_workspace_id": "baa1eb69-b324-433e-aa10-4bbf988965a8"
# META }
# META }
# META }
# MARKDOWN ********************
# ### Import Utilities
# CELL ********************
%run nb-notebook-utilities
# METADATA ********************
# META {
# META "language": "python",
# META "language_group": "synapse_pyspark"
# META }
It works.
Thank you all for the support! Solved
Wijnand
Hi @wbeke , Thank you for reaching out to the Microsoft Community Forum.
The error you're encountering is due to the submission of an incomplete platform file. The API requires a fully defined platform configuration, which must include essential fields such as schema, name, metadata and dependencies, particularly the details related to your Lakehouse.
To avoid overwriting any existing configurations, you should first retrieve the current notebook definition. This includes both the notebook content and the platform file. You can do this by making a GET request to the API. Once you have the existing platform file, locate the dependencies.lakehouse section and update it with your new Lakehouse information. Be sure that all other required fields are still present in the file. After you've updated the platform file, you’ll need to Base64 encode both the notebook content and the platform file. Then, include these encoded components in the request body of a POST request to update the notebook.
Finally, ensure your account has the necessary permissions in Microsoft Fabric and that you're using a valid Microsoft Entra ID token to authenticate your API requests.
If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
Thnaks forthe reposnse,
So what is stated here (Items - Update Notebook Definition - REST API (Notebook) | Microsoft Learn) as body:
{
"definition": {
"parts": [
{
"path": "notebook-content.py",
"payload": "IyBGYWJyaWMgbm90ZWJv...",
"payloadType": "InlineBase64"
},
{
"path": ".platform",
"payload": "ZG90UGxhdGZvcm1CYXNlNjRTdHJpbmc=",
"payloadType": "InlineBase64"
}
]
}
}
is not correct?
I test this exact code , indeed it failed. But what is the exact definition of the body?
Hi @wbeke
to me it looks like Your `.platform` part is invalid because you’re only sending the lakehouse block (and a kernel_info block) – you’re not sending a complete, valid `.platform` file. The service expects the full platform JSON (including `schema`, `name`, `metadata` wrappers, existing dependencies, language, etc.), and when you omit everything else it rejects it as “Invalid platform file.”
In addition, the `updateDefinition` call always requires you to re‑submit all of the notebook’s parts (both the `.platform` part and the main notebook content). You can’t do an “incremental” patch of just the lakehouse settings.
Thanks @nilendraFabric ,
I was abel to get the definition of the notebook. So by sending it as is back to the rest api endpoint I thought I would not get any errors. But I did:
What I send:
https://api.fabric.microsoft.com/v1/workspaces/$workspaceId/notebooks/$notebookId/updateDefinition?updateMetadata=True
Body :
{
"displayName": "nb_correct",
"description": "fabric rest api 101",
"type": "Notebook",
"definition": {
"parts": [
{
"path": "notebook-content.ipynb",
"payload": "eyJjZWxscyI6W3siY2VsbF90eXBlIjoiY29kZSIsInNvdXJjZSI6W10sIm91dHB1dHMiOltdLCJleGVjdXRpb25fY291bnQiOm51bGwsIm1ldGFkYXRhIjp7Im1pY3Jvc29mdCI6eyJsYW5ndWFnZSI6InB5dGhvbiIsImxhbmd1YWdlX2dyb3VwIjoic3luYXBzZV9weXNwYXJrIn0sImNlbGxTdGF0dXMiOiJ7XCJXaWpuYW5kIEJla2VcIjp7XCJzZXNzaW9uX3N0YXJ0X3RpbWVcIjpudWxsLFwiZXhlY3V0aW9uX3N0YXJ0X3RpbWVcIjpcIjIwMjUtMDQtMjRUMTM6NDc6NTIuODk2MzUyMVpcIixcImV4ZWN1dGlvbl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==",
"payloadType": "InlineBase64"
},
{
"path": ".platform",
"payload": "ewogICIkc2NoZW1hIjogImh0dHBzOi8vZGV2ZWxvcGVyLm1pY3Jvc29mdC5jb20vanNvbi1zY2hlbWFzL2ZhYnJpYy9naXRJbnRlZ3JhdGlvbi9wbGF0Zm9ybVByb3BlcnRpZXMvMi4wLjAvc2NoZW1hLmpzb24iLAogICJtZXRhZGF0YSI6IHsKICAgICJ0eXBlIjogIk5vdGVib29rIiwKICAgICJkaXNwbGF5TmFtZSI6ICJuYl9jb3JyZWN0IiwKICAgICJkZXNjcmlwdGlvbiI6ICJOZXcgbm90ZWJvb2siCiAgfSwKICAiY29uZmlnIjogewogICAgInZlcnNpb24iOiAiMi4wIiwKICAgICJsb2dpY2FsSWQiOiAiMDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwIgogIH0KfQ==",
"payloadType": "InlineBase64"
}
]
},
"updateRequest": true
}
You can read this because it is an emty notebook :-). So nothing to hide.
But the response is:
{
"requestId": "116abff9-c72c-48c9-8c39-c7123559cdd8",
"errorCode": "InvalidInput",
"moreDetails": [
{
"errorCode": "InvalidParameter",
"message": "'updateRequest' is a required parameter"
}
],
"message": "The request has an invalid input"
}
What am I doing wrong?
Thanks
Wijnand
User | Count |
---|---|
4 | |
4 | |
2 | |
2 | |
2 |
User | Count |
---|---|
17 | |
15 | |
11 | |
6 | |
5 |