Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
All,
I have registered my application and got the client id. Note, I have used 'Native' option while registration.
My requirement is to push data from python script.
I have tried with ADOL, it seems fine, but i tried with 'request' package & called PowerBI's API
to push the data into my workspace.
from datetime import datetime
from random import randint
import time
import requests
import json
with open('sample.json') as json_file:
json_data = json.load(json_file)
print(json_data)
url = 'https://login.microsoftonline.com/common/oauth2/token'
data = {
'grant_type': 'password',
'scope': 'https://api.powerbi.com',
'resource': 'https://analysis.windows.net/powerbi/api',
'client_id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'username': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'password': 'xxxxxxx'
}
r = requests.post(url, data=data)
access_token = r.json().get('access_token')
print(access_token)
header = {'Authorization': 'Bearer {}'.format(access_token), 'Content-Type': 'application/json', }
api = requests.put('https://api.powerbi.com/v1.0/myorg/datasets?defaultRetentionPolicy=basicFIFO', headers=header, json=json_data)
print("API Result: {}\n{}\n".format(api.status_code, api.text))
# r = requests.post('https://api.PowerBI.com/v1.0/myorg/datasets', json.dumps(data), verify = False)
Error Message:
API Result: 404
{
"error":{
"code":"","message":"No HTTP resource was found that matches the request URI 'http://api.powerbi.com/v1.0/myorg/datasets?defaultRetentionPolicy=basicFIFO'."
}
}
I just used the same json body file given in the powerbi reference site.
I created the dataset by using below the link successfully.
https://docs.microsoft.com/en-us/rest/api/power-bi/pushdatasets/datasets_postdataset#code-try-0
Note: I am able to view the list of Datasets by using the below API.
api = requests.get('https://api.powerbi.com/v1.0/myorg/datasets', headers=header)
print("API Result: {}\n{}\n".format(api.status_code, api.text))
this API is working, but the POST method to push the dataset is not working. How? what is the missing piece here?
any help would be really appreciable!
any inputs ?
Team,
Please let me know do i need to get in touch with some support team for this.
any thoughts?
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
7 | |
6 | |
3 | |
2 | |
2 |