Forum Discussion
Anonymous
1 year agoNot applicable
Workload Development Toolkit CRUD APIs
Hi there, I am trying to generate Authentication bearer token on the fly, to create Datawarehouse via sample workload using the POST APIs available for it. How to: Create warehouses with case-inse...
- 1 year ago
Hi Anonymous,
You could try python in Fabric notebook. This way you don't have to worry about setting up access token retrieval since you can directly get it from Fabric. The following code will allow you to call any REST API in Fabric.
#Helper function to call Fabric REST API from notebookutils import mssparkutils as msu import requests import time def call_fabric_api(method, uri, payload=None): endpoint = "https://api.fabric.microsoft.com/v1" # Get PBI Access token and have it in the header for Authorization headers = { "Authorization": "Bearer " + msu.credentials.getToken("pbi"), "Content-Type": "application/json" } #Create new session and try sending a request to the Fabric REST API session = requests.Session() try: url = f"{endpoint}/{uri}" response = session.request(method, url, headers=headers, json=payload, timeout=120) print(response.json()) return response.json() except requests.RequestException as ex: print(ex)But if you are looking for access token specifically, the following is the CURL format that I normally use with Postman
curl --location 'https://login.microsoftonline.com/<Tenant ID>/oauth2/token?Content-Type=application%2Fx-www-form-urlencoded' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=client_credentials' \ --data-urlencode 'client_id=<Service Principal ID or Username>' \ --data-urlencode 'client_secret=<Secret or Password>' \ --data-urlencode 'resource=https://management.azure.com/'
v-prasare
1 year agoCommunity Support
Hi @Sanket9831,
Hope your doing well.
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution we have provided for your issue worked? or let us know if you need any further assistance here?
Your feedback is important to us, Looking forward to your response.
Thanks,
Prashanth Are
MS Fabric community support.