Powershell 流数据集中的请求错误(错误#400)

Powershell 流数据集中的请求错误(错误#400),powershell,powerbi,Powershell,Powerbi,我正在使用Powershell脚本每分钟将数据上传到PowerBI中的流式数据集(它由Windows任务调度器安排)。 我正在与奇怪的错误作斗争,这个错误没有改变任何东西 这是我的代码: function invokeRest() { $endpoint = "https://api.powerbi.com/beta/..." $query = @(Invoke-Sqlcmd -Query "select * from LS.dbo.live_Holdbacks;" -ServerIn

我正在使用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,并且传递了字符串