流式数据集中的错误请求(错误#400)
Bad request(error #400) in streaming dataset
我正在使用 Powershell 脚本每分钟将数据上传到 PowerBI 中的流式数据集中(使用 Windows 任务计划程序安排)。
我正在为奇怪的错误而苦苦挣扎,这个错误出现时没有任何改变。
这是我的代码:
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 获取的,每个 URL 都可以,我在控制台中得到的所有内容都是这样的:
The remote server returned an error: (400) Bad Request.
它突然停止工作...有人知道如何处理它吗?
我想通了!问题与其中一个字段有关 - 它的类型设置为 Number 并且有字符串传递给它。
我正在使用 Powershell 脚本每分钟将数据上传到 PowerBI 中的流式数据集中(使用 Windows 任务计划程序安排)。 我正在为奇怪的错误而苦苦挣扎,这个错误出现时没有任何改变。
这是我的代码:
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 获取的,每个 URL 都可以,我在控制台中得到的所有内容都是这样的:
The remote server returned an error: (400) Bad Request.
它突然停止工作...有人知道如何处理它吗?
我想通了!问题与其中一个字段有关 - 它的类型设置为 Number 并且有字符串传递给它。