Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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?
User | Count |
---|---|
15 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
17 | |
11 | |
5 | |
4 | |
3 |