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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
LittleMarie_MT
Frequent Visitor

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url

Trying to collect activity data from the cloud following instructions here https://learn.microsoft.com/en-us/rest/api/power-bi/admin/get-activity-events,

keep getting this error: requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='2026-02-13T00:00:00.000Z'&end...

 

What is wrong with this request?

 

1 ACCEPTED SOLUTION
LittleMarie_MT
Frequent Visitor

Solution found. Here are correct date formats accepted by API:

#Set Power BI REST API to get Activities for today
url = "https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='" + activityDate + "T00:00:00'&endDateTime='" + activityDate + "T23:59:59'"

(found in this post: https://community.fabric.microsoft.com/t5/Developer/Power-BI-Get-Activity-REST-API/m-p/3564225)

 

Or alternatevely the following transformations helped to achieve the proper date:

 

day = datetime.utcnow().date() - timedelta(days=1)
day = datetime.combine(day, datetime.min.time())
start_of_day = datetime(day.year, day_utc.month, day_utc.day, 0, 0, 0)
start_param = f"'{start_of_day .strftime('%Y-%m-%dT%H:%M:%SZ')}'"
 

View solution in original post

1 REPLY 1
LittleMarie_MT
Frequent Visitor

Solution found. Here are correct date formats accepted by API:

#Set Power BI REST API to get Activities for today
url = "https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='" + activityDate + "T00:00:00'&endDateTime='" + activityDate + "T23:59:59'"

(found in this post: https://community.fabric.microsoft.com/t5/Developer/Power-BI-Get-Activity-REST-API/m-p/3564225)

 

Or alternatevely the following transformations helped to achieve the proper date:

 

day = datetime.utcnow().date() - timedelta(days=1)
day = datetime.combine(day, datetime.min.time())
start_of_day = datetime(day.year, day_utc.month, day_utc.day, 0, 0, 0)
start_param = f"'{start_of_day .strftime('%Y-%m-%dT%H:%M:%SZ')}'"
 

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.