0
我使用Powershell腳本將數據每分鐘上傳到PowerBI中的流式數據集(它使用Windows任務計劃程序計劃)。 我正在爲奇怪的錯誤而掙扎,這種錯誤似乎沒有改變任何東西。流式數據集中的錯誤請求(錯誤#400)
這是我的代碼:
function invokeRest()
{
$endpoint = "https://api.powerbi.com/beta/..."
$query = @(Invoke-Sqlcmd -Query "select * from LS.dbo.live_Holdbacks;" -ServerInstance $env:computername)
$RetArray = @()
Foreach ($row in $query) {
$payload = @{
"id" = $row.LiveHoldbackID
"RefreshDate" = $row.RefreshDate.ToString("HH:mm")
"CreatedBy" = $row.CreatedBy
"Campaign Code" = $row.CampaignCode
"Campaign Description" = $row.CampaignDescription
"Comment" = $row.Comment
"Customer Number" = $row.CustomerNumber
"Country" = $row.Country
"holdback" = $row.holdback
"upselling" = $row.upselling
}
$RetArray += $payload
}
Write-Host (ConvertTo-Json @($RetArray));
Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json @($RetArray)) -Verbose
}
function ClearDataset([string]$authToken)
{
Clear-PBITableRows -authToken $authToken -dataSetName "DEV_live_holdbacks_no_History_1min" -tableName "RealTimeData" -Verbose
}
Import-Module -Name PowerBIPS
$authToken = Get-PBIAuthToken -ClientId "...." -Credential (new-object System.Management.Automation.PSCredential("......",(ConvertTo-SecureString -String "...." -AsPlainText -Force)))
$group = Get-PBIGroup -authToken $authToken -name "..."
Set-PBIGroup -id $group.id
$dataSets = Get-PBIDataSet -authToken $authToken -name "DEV_live_holdbacks_no_History_1min" -includeTables -Verbose
#ClearDataset $authToken
try {
ClearDataset $authToken
invokeRest
}
catch {
Write-Host 'Sth goes bad'
Write-Host $_
# do something with $_, log it, more likely
}
API信息直接從PowerBI拍攝,每一個網址就可以了,而我在控制檯得到的一切是這樣的:
The remote server returned an error: (400) Bad Request.
它只是突然停了下來工作......任何人都知道如何處理它?