Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Asynchronous refresh with the PBI API, unable to locate refreshid from POST to refreshes

Hello,

 

I try to refresh a Power BI dataset programmatically by sending post request to PBI API endpoint: datasets/<datasetid>/refreshes.

 

The documentation (https://docs.microsoft.com/en-us/power-bi/connect-data/asynchronous-refresh) states: The response also includes a location response-header field to point the caller to the refresh operation that was just created/accepted. Location is that of the new resource which was created by the request, which includes the refreshId.

 

I need to fetch the refreshid but I don't know how.

 

I used following Powershell code to refresh the dataset:

Please let me know how I can fetch the refreshid, thanks in advance!

 

Login-PowerBI
$XmlaQuery = @"
{
  "refresh": {
    "type": "full",
    "objects": [
      {
        "database": "<Datamodel>",
        "table": "<Table>"
      }
    ]
  }
}
"@

# URL is a relative or absolute URL of the Power BI entity to access. 
Invoke-PowerBIRestMethod -Url 'datasets/<datasetid>/refreshes' -Method Post -Body $XmlaQuery 

 

 

 

 

4 REPLIES 4
Anonymous
Not applicable

This has not been solved. If the documentation state that a requestId is returned in the Location header there should be an easy implementation right? 

please let me know!

lbendlin
Super User
Super User

Run 

Invoke-PowerBIRestMethod -Url 'datasets/<datasetid>/refreshes' -Method GET 

after posting the request.  That will give you the requestid and the status.

Anonymous
Not applicable

Hi @lbendlin,

 

That's correct and my current workaround. However I am really curious why POST does not return a location header since the documentation states:

 

The response also includes a location response-header field to point the caller to the refresh operation that was just created/accepted. Location is that of the new resource which was created by the request, which includes the refreshId.

 

 

of course the documentation could never be wrong...

Invoke-PowerBIRestMethod (MicrosoftPowerBIMgmt.Profile) | Microsoft Docs

 

It sure returns a System.Object . It just happens to be empty. What I think is happening is that the implementation is stripping away the headers

powerbi-powershell/InvokePowerBIRestMethod.cs at master · microsoft/powerbi-powershell · GitHub

 

You may need to reinvent the wheel and do all the HTTP calls manually to get the response headers. Might not be worth the effort.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors