Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
karthipowerbi
Regular Visitor

PUSH DATA Using Python's Request package - API Error 404

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!

3 REPLIES 3
karthipowerbi
Regular Visitor

any inputs ?

Team,

 

Please let me know do i need to get in touch with some support team for this.

any thoughts?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.