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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
PG_MTA_PowerBI
New Member

API Integration with Python Script

Hello guys,

I'm trying to integrate my data directly from an API to PowerBI with a Python script (see below).

Im downloading two different sets of data with two similar scripts: One for the product details and one for the model details.

 

"""
# installation the source package

# pip install --extra-index-url Source@package.com

"""

import os
#=================
# LOGIN/SETTTINGS
#=================

os.environ["Source_API_ENDPOINT"] = "hidden"
os.environ["Source_API_USER"] = "hidden"
os.environ["Source_API_PASSWORD"] =  "hidden"
os.environ["Source_ENV"]= "hidden"

MAX_SIZE = 30
FETCH_ALL = True # False =  MAX_SIZE 


#=================
# imports
#=================

from Source.api.endpoints import ProductAPI, ProductModelAPI
import pandas as pd

gen_models  = ProductModelAPI.objects.stream(convert_to_model=False)


def fetch_data(gen_models):
    data = []
    
    if FETCH_ALL:
        data = [x for x in gen_models]

    else:
        data = []
        for rx in range(MAX_SIZE):
            data.append(next(gen_models))
    return data 
    
    
#=================
#convert to pandas dataframe
#=================

models = pd.DataFrame(fetch_data(gen_models))

 

 

For the integration of the product data there is no problem and all 12.000+ rows are loaded from the API into PowerBI.

Whereas the model data loads some time and then gives the following error:

Error_message.PNG

 

I've already tried the script for the model data in powershell with an extra code-line to give me an csv-file and everything worked fine. I got my data set with all 7200+ models in a csv-file. So maybe the script might not be the problem here.

 

To further investigate the error in PowerBI, I limited the amount of models to download by varying the "MAX_SIZE" line and with which I was able to download up to 7200 models until the Error occured again.

 

I can't quiet get my head around why the script works for the bigger dataset of products but not for the smaller data set of models. And why I'm able to download parts of the model-set but not all of it without getting an Error.

 

I hope that some of you guys might have an idea regarding the topic.

Thanks in advance

Marcel

2 REPLIES 2
amitchandak
Super User
Super User

@PG_MTA_PowerBI,

print (models)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak for your answer, but this didn't fix the problem. Still same error.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.