Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
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!
Run
Invoke-PowerBIRestMethod -Url 'datasets/<datasetid>/refreshes' -Method GET
after posting the request. That will give you the requestid and the status.
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.
User | Count |
---|---|
17 | |
11 | |
5 | |
4 | |
3 |