The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredAsk the Fabric Databases & App Development teams anything! Live on Reddit on August 26th. Learn more.
Hello,
I want to load a table in Fabric following this documentation: Lakehouse management API - Microsoft Fabric | Microsoft Learn .
It uses the following API call:
POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId}/tables/demo/load
{
"relativePath": "Files/demo.csv",
"pathType": "File",
"mode": "overwrite",
"formatOptions":
{
"header": true,
"delimiter": ",",
"format": "CSV"
}
}
However for me this returns : "An invalid request has been received: ' 'loadTableRequest' is a required parameter.'."
How should I add this parameter to the request?
Solved! Go to Solution.
Hi @Anonymous ,
First, note that:
To use the Fabric REST API, you first need to get a Microsoft Entra token for the Fabric service. Then use the token in the authorization header of the API call.
You can click on the official document below to learn:
Fabric API quickstart - Microsoft Fabric REST APIs | Microsoft Learn
Second, this API is asynchronous, so it requires three steps:
Finally, run the following command in the notebook corresponding to your lakehouse, replacing "YOUR_ACCESS_TOKEN", {workspaceId}, {lakehouseId}, and the products table name with the appropriate values.
import requests
url = https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId} /tables/products/load
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
data = {
"relativePath": "Files/products.csv",
"pathType": "File",
"mode": "overwrite",
"formatOptions": {
"header": True,
"delimiter": ",",
"format": "CSV"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())
I ran it successfully.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Hi @Anonymous ,
First, note that:
To use the Fabric REST API, you first need to get a Microsoft Entra token for the Fabric service. Then use the token in the authorization header of the API call.
You can click on the official document below to learn:
Fabric API quickstart - Microsoft Fabric REST APIs | Microsoft Learn
Second, this API is asynchronous, so it requires three steps:
Finally, run the following command in the notebook corresponding to your lakehouse, replacing "YOUR_ACCESS_TOKEN", {workspaceId}, {lakehouseId}, and the products table name with the appropriate values.
import requests
url = https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/lakehouses/{lakehouseId} /tables/products/load
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
data = {
"relativePath": "Files/products.csv",
"pathType": "File",
"mode": "overwrite",
"formatOptions": {
"header": True,
"delimiter": ",",
"format": "CSV"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())
I ran it successfully.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Thank you, the following was actually missing in my request
"Content-Type": "application/json"
btw, is there any other documentation about this api endpoint? What if I want to go beyond this example and load multiple parquet files from a folder?