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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Nyx
Frequent Visitor

Windows PowerShell ISE Invoke-RestMethod 404 error

Hi,

Anyone see what is wrong with the below in Windows PowerShell ISE?

It works with -Method Post but not Put. Testing overwriting the data every 12 seconds.

 

while (1 -eq 1 ){
$command=

$data = Invoke-RestMethod -Method Get "https://api.xxxxxxxxxx"
$endpoint = "https://api.powerbi.com/beta/xxxxxxxxxxxxxxx/datasets/xxxxxxxxxxx/rows?experience=power-bi&key=xxxxxxxxxxxxxxxxx"
$payload = @{
"ticker" =$data."ticker"
"v" =$data."results"."v"
"vw" =$data."results"."vw"
"o" =$data."results"."o"
"c" =$data."results"."c"
"h" =$data."results"."h"
"l" =$data."results"."l"
"t" =$data."results"."t"
"n" =$data."results"."n"
}
Invoke-RestMethod -Method Put -Uri "$endpoint" -Body (ConvertTo-Json @($payload))

$command
start-sleep -seconds 12
}

 

Returns:

Invoke-RestMethod : The remote server returned an error: (404) Not Found.
At C:\Users\xxxxx\OneDrive - xxxxx\Desktop\API stock test.ps1:17 char:1
+ Invoke-RestMethod -Method Put -Uri "$endpoint" -Body (ConvertTo-Json ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

1 REPLY 1
lbendlin
Super User
Super User

That's working as designed.  Were you expecting a different behavior?

 

BTW you are missing the table name.

 

Push Datasets - Datasets PostRows - REST API (Power BI Power BI REST APIs) | Microsoft Learn

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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