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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power Shell script to push data to Power BI API

All,

 

NOTE: I am not a developer, trying to do the below from an online example.

 

I am using the following power shell script to push data to a power BI API and data set. It used to work fine, but then I started getting the following error

======================================

Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At line:28 char:5
+ Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestM
ethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMeth
odCommand

=================================

Script is pretty simple - just getting local machine stats and posting to power BI API

 

$endpoint = "https://api.powerbi.com/beta/de3e5d90-25ee-443e-908a-0590e39c4dff/datasets/abfa7618-cc8e-49c3-bffe-0..."

while($true)
{

$ComputerCPU = (Get-WmiObject -Class win32_processor -ErrorAction Stop | Measure-Object -Property LoadPercentage -Average | Select-Object Average).Average

$ComputerMemory = Get-WmiObject -Class win32_operatingsystem -ErrorAction Stop
$UsedMemory = $ComputerMemory.TotalVisibleMemorySize - $ComputerMemory.FreePhysicalMemory
$Memory = (($UsedMemory/ $ComputerMemory.TotalVisibleMemorySize)*100)
$RoundMemory = [math]::Round($Memory, 2)

$Date = Get-Date -DisplayHint Date -Format MM/dd/yyyy

$Time = Get-Date -DisplayHint Time -Format HH:mm:ss

#$RoundMemory
#$ComputerCPU
#$Date
#$Time

$payload = @{
"Date" =$Date
"Time" =$Time
"CPU" = $ComputerCPU
"Memory" = $RoundMemory
}
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))

Write-Host "Date: " $Date " Time: " $Time " CPU: " $ComputerCPU " Memory: " $RoundMemory

sleep 2
}

============================

Why would this suddenly stop working?

If I hit the full url : https://api.powerbi.com/beta/de3e5d90-25ee-443e-908a-0590e39c4dff/datasets/abfa7618-cc8e-49c3-bffe-0...

I get a 404

If I hit : https://api.powerbi.com/beta/de3e5d90-25ee-443e-908a-0590e39c4dff/datasets/abfa7618-cc8e-49c3-bffe-0...

I get a 403

 

can someone help me fix this?

 

Thanks

Ravina

0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.