Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
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
User | Count |
---|---|
8 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |