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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bobmarley
Frequent Visitor

Pushing real time data with API Authorization problem

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?

1 ACCEPTED SOLUTION
bobmarley
Frequent Visitor

I found out the problem. It was the proxy related issue. 401 status code was thrown due to proxy settings on my PC and it wasn't related to Piower BI.

View solution in original post

1 REPLY 1
bobmarley
Frequent Visitor

I found out the problem. It was the proxy related issue. 401 status code was thrown due to proxy settings on my PC and it wasn't related to Piower BI.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Kudoed Authors