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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
smerugu28
Regular Visitor

Python Script in Power BI

Hi Friends,

 

I am writing first python script in Power BI but but I get some nasty error which goes over my head.

 

Here is my script

 

 

 

 

 

import requests
import pandas as pd

# Set the request parameters
url = 'https://myinstance.xyz-wow.com/api/now/table/incident'
user = 'abc'
password = 'xyz'
headers = {"Content-Type": "application/json", "Accept": "application/json"}

# Do the HTTP request within a try-except block to handle potential errors
try:
    response = requests.get(url, auth=(user, password), headers=headers)
    response.raise_for_status() # This will raise an exception for HTTP errors
    data = response.json()
    
    # Since Power BI expects a DataFrame, we'll convert the resulting data to a DataFrame
    # It is assumed data['result'] contains the records you want to display
    df = pd.DataFrame(data['result'])
    
    # Output the DataFrame into Power BI
    # Please note that the last dataframe in the script will be the one imported into Power BI
    df
except requests.exceptions.RequestException as e:
    print(f'An error occurred: {e}')

 

 

 

 

 

This is what I am getting for it

 

smerugu28_0-1716627877472.png

 

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @smerugu28 
There could be various reasons for the error message you attached.

Please refer to the linked discussions about similar challenges :

https://community.fabric.microsoft.com/t5/Desktop/Power-BI-Python-ADO-NET-Python-Script-Error/m-p/84...

https://stackoverflow.com/questions/58522535/ado-net-error-trying-to-run-python-script-in-powerbi

And the linked videos:
https://www.youtube.com/watch?v=5D0BkNsu5CM

https://www.youtube.com/watch?v=fd7OYfeSGXE

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Anonymous
Not applicable

Thank you for your prompt reply! @Ritaf1983 

 

Hi @smerugu28 

 

Ensure that the API endpoint is accessible with the credentials you're using. You can do this by attempting to access the URL directly in a web browser or using a tool like Postman.

 

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you for your prompt reply! @Ritaf1983 

 

Hi @smerugu28 

 

Ensure that the API endpoint is accessible with the credentials you're using. You can do this by attempting to access the URL directly in a web browser or using a tool like Postman.

 

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ritaf1983
Super User
Super User

Hi @smerugu28 
There could be various reasons for the error message you attached.

Please refer to the linked discussions about similar challenges :

https://community.fabric.microsoft.com/t5/Desktop/Power-BI-Python-ADO-NET-Python-Script-Error/m-p/84...

https://stackoverflow.com/questions/58522535/ado-net-error-trying-to-run-python-script-in-powerbi

And the linked videos:
https://www.youtube.com/watch?v=5D0BkNsu5CM

https://www.youtube.com/watch?v=fd7OYfeSGXE

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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