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
aimjb75
New Member

Push API get request with Python

Hi, 

I have a python program that posts data via requests.post using the Push URL. This works fine. 

 

Is there a way to request.get with a get URL? This would allow me to check what data I already have in the push dataset on Power BI and only post the new data, for example if the program stopped working in the middle of the day. 

 

Thanks for any help

1 REPLY 1
AntrikshSharma
Community Champion
Community Champion

@aimjb75 

import requests
import msal

app_id = ''
tenant_id = ''

username = ''
password = ''

authority_url = f'https://login.microsoftonline.com/{tenant_id}'
scopes = [r'https://analysis.windows.net/powerbi/api/.default']

client = msal.PublicClientApplication(app_id, authority=authority_url)
response = client.acquire_token_by_username_password(username, password, scopes)
access_id = response.get('access_token')

endpoint = 'https://api.powerbi.com/v1.0/myorg/groups'
headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {access_id}'
}
response_request = requests.get(endpoint, headers=headers)

if response_request.status_code == 200:
    result = response_request.json()
    for item in result['value']:
        print(item['name'])

 

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.