Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 18051

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.

$
0
0

Windows 2012R2 x64

PowerShell ISE

 

Script from PBI as is:

while($true){

$endpoint = "https://api.powerbi.com/beta/xxxxxxxx"

$payload = @{

"Measured" =123
"DateTime" =Get-Date -Format F
"MachineName" ="Test"
"TargetValue" =1672
"MinValue" =0
"MaxValue" =6000

}
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload))
}

 

Return folowing error:

Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:16 char:1
+ Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($payload ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

What needs to be fixed ?

 

The same script working fine at Windows 10 Pro.

 


Viewing all articles
Browse latest Browse all 18051

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>