2
votes

I am getting an Unauthorized response when trying to import a pbix into powerbi embedded. This was working a few days ago as far as I can remember. Here is the code below I am using, it is basically the same from the github example. Has something recently changed? Thanks.

        // Create a dev token for import
        var devToken = PowerBIToken.CreateDevToken(workspaceCollectionName, workspaceId);
        using (var client = CreateClient(devToken))
        {
            // Import PBIX file from the file stream
            var import = await client.Imports.PostImportWithFileAsync(workspaceCollectionName, workspaceId, fileStream, datasetName);

            // Example of polling the import to check when the import has succeeded.
            while (import.ImportState != "Succeeded" && import.ImportState != "Failed")
            {
                import = await client.Imports.GetImportByIdAsync(workspaceCollectionName, workspaceId, import.Id);
                Console.WriteLine("Checking import state... {0}", import.ImportState);
                Thread.Sleep(1000);
            }

        }
1

1 Answers

0
votes

Figured out the issue it was on my side after some refactoring. I was passing in an incorrect workspace id. Not sure why I receive an unauthorized response back when I pass in an incorrect workspace id.