Forum Discussion

Binway's avatar
Binway
Icon for Helper II rankHelper II
4 years ago
Solved

Embedded Lab cannot convert from string to system.guid

I am following some lab content I found that demonstrates how to embed Power BI content into a web app.  The PDfs are fairly straightforward but when I go to debug the code I get an error in the PBIE...
  • Binway's avatar
    4 years ago

    Got it working.

    Had to add a bit of extra to the code supplied in git to some classes as per below:

          /* renamed the variable to indicate it is a string for workspaceId and reportId*/
            private static readonly string strworkspaceId = ConfigurationManager.AppSettings["app-workspace-id"];
            private static string datasetId = ConfigurationManager.AppSettings["dataset-id"];
            private static readonly string strreportId = ConfigurationManager.AppSettings["report-id"];

    Then in this class

      public static async Task<ReportEmbeddingData> GetReportEmbeddingData()
            {
    
                PowerBIClient pbiClient = GetPowerBiClient();
                /* in this class add the conversion to GUID*/
                Guid workspaceId = Guid.Parse(strworkspaceId);
                Guid reportId = Guid.Parse(strreportId);
    
                var report = await pbiClient.Reports.GetReportInGroupAsync(workspaceId, reportId);
                var embedUrl = report.EmbedUrl;
                var reportName = report.Name;

    But in here it has to go back to string in the GUID("D") format

      return new ReportEmbeddingData
                {
                    /*in here converted the GUID back to string*/
                    reportId = reportId.ToString("D"),
                    reportName = reportName,

    With the report working.