<?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 Embedded Lab cannot convert from string to system.guid in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Embedded-Lab-cannot-convert-from-string-to-system-guid/m-p/2716146#M38059</link>
    <description>&lt;P&gt;I am following some lab content I found that demonstrates how to embed Power BI content into a web app.&amp;nbsp; The PDfs are fairly straightforward but when I go to debug the code I get an error in the PBIEmbeddedManager.cs file that says "cannot convert from string to system.guid."&lt;/P&gt;&lt;P&gt;It is in relation to this line in the public class PbiEmbeddedManager:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static readonly string workspaceId = ConfigurationManager.AppSettings["app-workspace-id"];&lt;/LI-CODE&gt;&lt;P&gt;The code is picking the id up from the Web.config file which has the workspaceid from the url as instructed in the notes.&amp;nbsp; Unfortunately I have no idea how to alter the variable to a GUID or where to put it in the code.&amp;nbsp; It seems I need to add another class?? but I am not certain.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2022 08:24:17 GMT</pubDate>
    <dc:creator>Binway</dc:creator>
    <dc:date>2022-08-22T08:24:17Z</dc:date>
    <item>
      <title>Embedded Lab cannot convert from string to system.guid</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedded-Lab-cannot-convert-from-string-to-system-guid/m-p/2716146#M38059</link>
      <description>&lt;P&gt;I am following some lab content I found that demonstrates how to embed Power BI content into a web app.&amp;nbsp; The PDfs are fairly straightforward but when I go to debug the code I get an error in the PBIEmbeddedManager.cs file that says "cannot convert from string to system.guid."&lt;/P&gt;&lt;P&gt;It is in relation to this line in the public class PbiEmbeddedManager:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static readonly string workspaceId = ConfigurationManager.AppSettings["app-workspace-id"];&lt;/LI-CODE&gt;&lt;P&gt;The code is picking the id up from the Web.config file which has the workspaceid from the url as instructed in the notes.&amp;nbsp; Unfortunately I have no idea how to alter the variable to a GUID or where to put it in the code.&amp;nbsp; It seems I need to add another class?? but I am not certain.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 08:24:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedded-Lab-cannot-convert-from-string-to-system-guid/m-p/2716146#M38059</guid>
      <dc:creator>Binway</dc:creator>
      <dc:date>2022-08-22T08:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Embedded Lab cannot convert from string to system.guid</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Embedded-Lab-cannot-convert-from-string-to-system-guid/m-p/2721718#M38122</link>
      <description>&lt;P&gt;Got it working.&lt;/P&gt;&lt;P&gt;Had to add a bit of extra to the code supplied in git to some classes as per below:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;      /* 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"];&lt;/LI-CODE&gt;&lt;P&gt;Then in this class&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  public static async Task&amp;lt;ReportEmbeddingData&amp;gt; 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;&lt;/LI-CODE&gt;&lt;P&gt;But in here it has to go back to string in the GUID("D") format&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;  return new ReportEmbeddingData
            {
                /*in here converted the GUID back to string*/
                reportId = reportId.ToString("D"),
                reportName = reportName,&lt;/LI-CODE&gt;&lt;P&gt;With the report working.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Report.PNG" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/770897i142FA94719751B52/image-size/large?v=v2&amp;amp;px=999" role="button" title="Report.PNG" alt="Report.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 00:39:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Embedded-Lab-cannot-convert-from-string-to-system-guid/m-p/2721718#M38122</guid>
      <dc:creator>Binway</dc:creator>
      <dc:date>2022-08-24T00:39:52Z</dc:date>
    </item>
  </channel>
</rss>

