cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
XIOFEN_LIM
Helper I
Helper I

PowerShell Invoke-RestMethod 404 Not found.

Hi All,

 

In the process for loading up data streaming from SQL server to monitor live data and possibly create a dashboard. However after setting up the dashboard and a powershell script to push data to power bi, error shown.

 

Invoke-RestMethod : The remote server returned an error: (404) Not Found.

At C:\Users\EEM02117\OneDrive - Escatec\Projects\Power BI\POC\PushData.ps1:46 char:2

+     Invoke-RestMethod -Method Post -Uri "$Endpoint" -Body (ConvertTo- ...

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc

   eption

    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

Here’s the powershell script that pushes the data:

 

$Endpoint = https://api.powerbi.com/beta/1ee0c8fe-fb94-4c61-80fa-6d0ec79dc31f/Datasets/6062d4fe-7200-4b41-87f5-4...

 

while ($Dataset.Read()) { #push data to Power BI

       $payload = @{

              "UnitId" =$Dataset['UnitId']

              "SerialNumberInternal" =$Dataset['SerialNumberInternal']

              "SaleQuantityAmount" =$Dataset['Quantity']

              "DateCreated" =$Dataset['DateCreated']

       }

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

}

 

Any ideas? Would need a Power BI gateway configured?

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

If it is a non cloud data source, you need to configure a gateway.

Make sure you didn't disable the "historic data analysis".

You can also refer to the steps of this blog:

https://sqlitybi.com/streaming-data-from-sql-server-to-power-bi-using-powershell/?doing_wp_cron=1617... 

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

If it is a non cloud data source, you need to configure a gateway.

Make sure you didn't disable the "historic data analysis".

You can also refer to the steps of this blog:

https://sqlitybi.com/streaming-data-from-sql-server-to-power-bi-using-powershell/?doing_wp_cron=1617... 

@V-lianl-msft 

Got it.. Thank you!

Helpful resources

Announcements
Power BI Show Episode 10 Recap

The Power BI Community Show

Watch the playback when Amit Chandak, a Power BI Super User, demos how to use Field Parameters to make reports more dynamic.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.

Ignite 2022

What's Next at Microsoft Ignite 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Top Kudoed Authors