Forum Discussion

HassanRizvi's avatar
HassanRizvi
New Member
1 year ago
Solved

Forbidden (403) error when using While statement in PowerShell URL

Hi, I am kind of new to the realm of PowerBI, and I am trying to make a real-time dashboard in Power BI service with a dummy dataset. I am using the streaming dataset module in PowerBi Service and ...
  • v-prasare's avatar
    1 year ago

    HassanRizvi,

    Can you try below powershell script once. this is working fine for me

     

     

    "<< API >>"
    > while ($true) {
    >>     $payload = @(
    >>         @{
    >>             "Date" = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ss.fffZ")  # Current UTC DateTime
    >>             "Name" = "AAAAA555555"
    >>             "Marks" = Get-Random -Minimum 0 -Maximum 100  # Generate a random number
    >>         }
    >>     )
    >>
    >>     $headers = @{
    >>         "Content-Type" = "application/json"
    >>     }
    >>
    >>     # Send data to Power BI
    >>     Invoke-RestMethod -Method Post -Uri "$endpoint" -Headers $headers -Body (ConvertTo-Json $payload -Depth 3)
    >>
    >>     Write-Host "Data sent at $(Get-Date)"
    >>
    >>     Start-Sleep -Seconds 10  # Wait for 10 seconds before the next update
    >> }

     

     

    PFB screenshot for same:

     

     

     

     

    '

    Thanks,

    Prashanth Are

    MS Fabric community support

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query