<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Uploading a PBIX file with  PostImportWithFileAsyncInGroup does not return datasets in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Uploading-a-PBIX-file-with-PostImportWithFileAsyncInGroup-does/m-p/4632667#M60132</link>
    <description>&lt;P&gt;I though that this was the case.&lt;BR /&gt;I came up with this implementation:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;public async Task&amp;lt;Import&amp;gt; UpsertDataSet(Guid groupId, string path, string displayName)
{
    var pbiClient = await GetPowerBIClient() ?? throw new PowerBiException(PowerBiClientIsNull);

    using var pbixStream = new FileStream(path, FileMode.Open, FileAccess.Read);
    var import = await pbiClient.Imports.PostImportWithFileAsyncInGroup(groupId, pbixStream,
        datasetDisplayName: displayName,
        nameConflict: ImportConflictHandlerMode.CreateOrOverwrite,
        overrideModelLabel: true,
        overrideReportLabel: true);

    var importId = import.Id;
    var retry = 0;

    while (retry++ &amp;lt; MaxRetries)
    {
        var importState = ParseImportState(import.ImportState);

        if (importState is ImportState.Succeeded)
        {
            return import;
        }

        if (importState is ImportState.Failed)
        {
            throw new PowerBiException(ImportFailed);
        }

        await Task.Delay(500);

        import = await pbiClient.Imports.GetImportInGroupAsync(groupId, importId);
    }

    throw new PowerBiException(ImportFailed);
}

private static ImportState ParseImportState(string state)
{
    return state switch
    {
        "Succeeded" =&amp;gt; ImportState.Succeeded,
        "Failed" =&amp;gt; ImportState.Failed,
        "Publishing" =&amp;gt; ImportState.Publishing,
        _ =&amp;gt; ImportState.Unknown
    };
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Apr 2025 08:04:33 GMT</pubDate>
    <dc:creator>BartHuls</dc:creator>
    <dc:date>2025-04-01T08:04:33Z</dc:date>
    <item>
      <title>Uploading a PBIX file with  PostImportWithFileAsyncInGroup does not return datasets</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Uploading-a-PBIX-file-with-PostImportWithFileAsyncInGroup-does/m-p/4631696#M60118</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I'm trying to upload a Symantic Model in a PowerBi Workspace, using the c# PowerBiClient. I'm using the following code:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;public async Task&amp;lt;Import&amp;gt; UpsertDataSet(Guid groupId, string path, string displayName)
{
    var pbiClient = await GetPowerBIClient() ?? throw new PowerBiException(PowerBiClientIsNull);

    using var pbixStream = new FileStream(path, FileMode.Open, FileAccess.Read);
    var import = await pbiClient.Imports.PostImportWithFileAsyncInGroup(groupId, pbixStream, displayName, nameConflict: ImportConflictHandlerMode.CreateOrOverwrite);

    return await pbiClient.Imports.GetImportInGroupAsync(groupId, import.Id);
}&lt;/PRE&gt;&lt;P&gt;There are cases where the import.Datasets are not filled while the Model is uploaded.&lt;/P&gt;&lt;P&gt;I added and extra GetImportInGroupAsync to check if the model is updated. How come that the result is empty when the Model is updated.&lt;BR /&gt;I looked into the "Lineage" view and the the time of Refresh looks ok for the Semantic model&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 06:39:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Uploading-a-PBIX-file-with-PostImportWithFileAsyncInGroup-does/m-p/4631696#M60118</guid>
      <dc:creator>BartHuls</dc:creator>
      <dc:date>2025-04-01T06:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading a PBIX file with  PostImportWithFileAsyncInGroup does not return datasets</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Uploading-a-PBIX-file-with-PostImportWithFileAsyncInGroup-does/m-p/4632617#M60131</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1249726"&gt;@BartHuls&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="" data-start="170" data-end="244"&gt;Thank you for reaching out through the Microsoft Fabric Community Forum.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="" data-start="246" data-end="681"&gt;Based on my understanding, the issue arises because the import operation is asynchronous. The&lt;/P&gt;
&lt;P data-pm-slice="0 0 []"&gt;PostImportWithFileAsyncInGroup method returns an Import object immediately; however, the dataset metadata is not populated until the import process is fully completed. Your GetImportInGroupAsync call checks the status prematurely, before the import has finished, even though the Lineage view indicates that the model has been updated.&lt;/P&gt;
&lt;P class="" data-start="683" data-end="754"&gt;Kindly follow the steps below, which may help in resolving the issue:&lt;/P&gt;
&lt;OL data-start="756" data-end="1215"&gt;
&lt;LI class="" data-start="756" data-end="870"&gt;
&lt;P class="" data-start="759" data-end="870"&gt;After initiating the import, continuously poll the import status using GetImportInGroupAsync within a loop.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="871" data-end="990"&gt;
&lt;P class="" data-start="874" data-end="990"&gt;Monitor the ImportState&amp;nbsp;property until it changes to&amp;nbsp;Succeeded, indicating that the import has been completed.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="991" data-end="1071"&gt;
&lt;P class="" data-start="994" data-end="1071"&gt;Once the state is Succeeded,&amp;nbsp;the Datasets&amp;nbsp;property should be populated.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="" data-start="1072" data-end="1215"&gt;
&lt;P class="" data-start="1075" data-end="1215"&gt;Handle potential edge cases, such as import failures, large PBIX files (which may require additional time), and permission-related issues.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P class="" data-start="1217" data-end="1382"&gt;Polling ensures that you wait for the import process to be fully completed, including the population of dataset metadata, before accessing the&amp;nbsp;Datasets&amp;nbsp;property.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="" data-start="1384" data-end="1457"&gt;Additionally, you may refer to the following links for further details:&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group" target="_blank"&gt;Imports - Post Import In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/imports/get-import-in-group" target="_blank"&gt;Imports - Get Import In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://learn.microsoft.com/en-us/dotnet/api/microsoft.powerbi.api?view=azure-dotnet&amp;amp;viewFallbackFrom=powerbi-dotnet" target="_blank"&gt;Microsoft.PowerBI.Api Namespace - Azure for .NET Developers | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="" data-start="1966" data-end="2125"&gt;If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members facing similar queries.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P class="" data-start="2127" data-end="2139"&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 07:22:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Uploading-a-PBIX-file-with-PostImportWithFileAsyncInGroup-does/m-p/4632617#M60131</guid>
      <dc:creator>v-pnaroju-msft</dc:creator>
      <dc:date>2025-04-01T07:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading a PBIX file with  PostImportWithFileAsyncInGroup does not return datasets</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Uploading-a-PBIX-file-with-PostImportWithFileAsyncInGroup-does/m-p/4632667#M60132</link>
      <description>&lt;P&gt;I though that this was the case.&lt;BR /&gt;I came up with this implementation:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;public async Task&amp;lt;Import&amp;gt; UpsertDataSet(Guid groupId, string path, string displayName)
{
    var pbiClient = await GetPowerBIClient() ?? throw new PowerBiException(PowerBiClientIsNull);

    using var pbixStream = new FileStream(path, FileMode.Open, FileAccess.Read);
    var import = await pbiClient.Imports.PostImportWithFileAsyncInGroup(groupId, pbixStream,
        datasetDisplayName: displayName,
        nameConflict: ImportConflictHandlerMode.CreateOrOverwrite,
        overrideModelLabel: true,
        overrideReportLabel: true);

    var importId = import.Id;
    var retry = 0;

    while (retry++ &amp;lt; MaxRetries)
    {
        var importState = ParseImportState(import.ImportState);

        if (importState is ImportState.Succeeded)
        {
            return import;
        }

        if (importState is ImportState.Failed)
        {
            throw new PowerBiException(ImportFailed);
        }

        await Task.Delay(500);

        import = await pbiClient.Imports.GetImportInGroupAsync(groupId, importId);
    }

    throw new PowerBiException(ImportFailed);
}

private static ImportState ParseImportState(string state)
{
    return state switch
    {
        "Succeeded" =&amp;gt; ImportState.Succeeded,
        "Failed" =&amp;gt; ImportState.Failed,
        "Publishing" =&amp;gt; ImportState.Publishing,
        _ =&amp;gt; ImportState.Unknown
    };
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 08:04:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Uploading-a-PBIX-file-with-PostImportWithFileAsyncInGroup-does/m-p/4632667#M60132</guid>
      <dc:creator>BartHuls</dc:creator>
      <dc:date>2025-04-01T08:04:33Z</dc:date>
    </item>
  </channel>
</rss>

