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.
I have to automate the notebook using power automate of Invoke HTTP request used the fabric api POST https://api.fabric.microsoft.com/v1/workspaces/{{WORKSPACE_ID}}/items/{{ARTIFACT_ID}}/jobs/instances... and body is {
"executionData":{}
} i ended up having bad request error and I register an app in azure and get the client id client secret and tested using the below code I have the error of Error: 401 - {"requestId":"978734ec-410d-40ae-8a0b-faaf5938e6b5","errorCode":"Unauthorized","message":"The caller is not authenticated to access this resource"} for the below code how to overcome this issue
import requests
import json
# Step 1: Get Access Token
tenant_id = 'your_tenant_id'
client_id = 'your_client_id'
client_secret = 'your_client_secret'
scope = 'https://api.fabric.microsoft.com/.default'
grant_type = 'client_credentials'
token_url = f'https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token'
token_headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
token_body = {
'client_id': client_id,
'client_secret': client_secret,
'scope': scope,
'grant_type': grant_type
}
token_response = requests.post(token_url, headers=token_headers, data=token_body)
if token_response.status_code == 200:
access_token = token_response.json().get('access_token')
print("Access token retrieved successfully.")
else:
print(f"Error: {token_response.status_code} - {token_response.text}")
exit()
# Step 2: Execute Notebook
url = "https://api.fabric.microsoft.com/v1/workspaces/4a909421-5f1d-4bab-b83a-f6319ef0f9df/items/12914089-c..."
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
data = {
"executionData": {
# Include necessary execution parameters here
"param1": "value1",
"param2": "value2"
}
}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print("Notebook executed successfully.")
else:
print(f"Error: {response.status_code} - {response.text}")
Hi @santh00 ,
Thanks for using Fabric Community.
Can you please refer these docs?
Trigger A Fabric Notebook Through The API - Discover Microsoft Business Central (bertverbeek.nl)
Using an API in Power Automate with Entra ID authentication - Forward Forever
Manage and execute Fabric notebooks with public APIs - Microsoft Fabric | Microsoft Learn
https://youtu.be/W5gIpI9eRFY?si=7NW63U5qja-ouG-y
Hope this is helpful. Please do let me know incase of further queries.
Hello @santh00 ,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet.
Otherwise, will respond back with the more details and we will try to help .
Hi @santh00 ,
We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet.
Otherwise, will respond back with the more details and we will try to help .
User | Count |
---|---|
20 | |
17 | |
6 | |
2 | |
2 |
User | Count |
---|---|
51 | |
49 | |
17 | |
6 | |
4 |