cancel
Showing results for 
Search instead for 
Did you mean: 
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 Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!