Hello there,
I want to push the data to Power BI Real time API so that I can see data on real time in Power BI dashboard. I am using python to post data to the API Provided by Power BI. The problem is that some time it works and some time it doesn't. Sometimes it successfully post the data with 200 status code and sometimes it gives 401 Authorization required. If I referesh the Power BI page and then again post the data the 401 error goes away but it comes back after some time. below is the python code that through which I am trying to post the data.
import requests import json from datetime import datetime from random import randint import time url = "API URL" try: for i in range(100): print(i) date = datetime.now().strftime("%Y-%m-%dT%H:%M:%S") print(date) data = [{"date_time": date, "value": randint(0,200)}] #print(json.dumps(data)) r = requests.post(url, json.dumps(data), verify = False) print(r.status_code) print(r.reason) except Exception as e: print(e)
According to the oficial documentaion(can be found here) no authorization should be required.
For streaming datasets created using the Power BI service UI, as described in the previous paragraph, Azure AD authentication is not required. In such datasets, the dataset owner receives a URL with a rowkey, which authorizes the requestor to push data into the dataset with out using an Azure AD OAuth bearer token. Take now, however, that the Azure AD (AAD) approach still works to push data into the dataset
How to reslove this issue?