Forum Discussion
Fabric API Table load required parameters
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?
- Anonymous2 years ago
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:
- Use the OneLake API to upload files and folders to the "Files" section of your lakehouse.
- Submit the payload to the Table API request.
- Track the status of the operation until it completes.
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 TeamIf 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!
2 Replies
- AnonymousNot applicable
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:
- Use the OneLake API to upload files and folders to the "Files" section of your lakehouse.
- Submit the payload to the Table API request.
- Track the status of the operation until it completes.
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 TeamIf 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!- AnonymousNot applicable
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?