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
Syndicate_Admin
Administrator
Administrator

Script de Python en Power BI

Hola amigos,

Estoy escribiendo el primer script de Python en Power BI, pero recibo un error desagradable que se me pasa por la cabeza.

Aquí está mi guión

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}')

Esto es lo que estoy recibiendo por ello

smerugu28_0-1716627877472.png

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

¡Gracias por su pronta respuesta! @Ritaf1983

Hola @smerugu28

Asegúrese de que el punto de conexión de la API es accesible con las credenciales que estás usando. Puede hacerlo intentando acceder a la URL directamente en un navegador web o utilizando una herramienta como Postman.

Saludos

Jayleny

Si esta publicación ayuda, considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Syndicate_Admin
Administrator
Administrator

Hola @smerugu28
Puede haber varias razones para el mensaje de error que adjuntó.

Por favor, refiérase a las discusiones vinculadas sobre desafíos similares:

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

Y los vídeos enlazados:
https://www.youtube.com/watch?v=5D0BkNsu5CM

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

Si esta publicación ayuda, considere aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

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.

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.

Top Solution Authors