<?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: PowerBI Post Import In Group not working in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-Post-Import-In-Group-not-working/m-p/2501396#M35971</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/386310"&gt;@sachin131&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please check if it hit any following limitations, you can find the details in &lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group#limitations" target="_self"&gt;this official documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_0-1652084461443.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/711178iEFFDC3801CF2889B/image-size/large?v=v2&amp;amp;px=999" role="button" title="yingyinr_0-1652084461443.png" alt="yingyinr_0-1652084461443.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.ionos.com/digitalguide/websites/website-creation/what-does-the-404-not-found-error-mean/" target="_self"&gt;Error 404: what it means and how to fix it&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2022 08:26:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-05-09T08:26:00Z</dc:date>
    <item>
      <title>PowerBI Post Import In Group not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-Post-Import-In-Group-not-working/m-p/2495789#M35918</link>
      <description>&lt;P&gt;Hello&amp;nbsp;@All.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to upload one pbix report through "Post Import in Group" powerBI Rest API but getting 404 error. I followed the following link:&lt;BR /&gt;&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group#post-import-example" target="_blank"&gt;https://docs.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group#post-import-example&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is not helpful here. I am using following code. Please let me know if anyone can help me here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; var url = $"https://api.powerbi.com/v1.0/myorg/groups/{targetWorkspaceId}/imports?datasetDisplayName={downloadedDataset.Name}&amp;amp;nameConflict=Overwrite";
string boundary = String.Format("----------{0:N}", Guid.NewGuid());
string contentType = "multipart/form-data; boundary=" + boundary;

using (MemoryStream ms = new MemoryStream())
{
    downloadedReportStream.CopyTo(ms);
    var file_bytes = ms.ToArray();

    byte[] formData = GetMultipartFormData(boundary, report.Name+".pbix", file_bytes);

    var httpWebResponse = PostForm(url, contentType, formData, "Authorization", String.Format("Bearer {0}", GetPBIAccessToken()));
    var responseStatusCode = httpWebResponse.StatusCode.ToString();
    Console.WriteLine("imported pbix ", responseStatusCode);
}

//private methods

private static byte[] GetMultipartFormData(string boundary, string fileName, byte[] fileBytes)
        {
            Stream formDataStream = new System.IO.MemoryStream();

            // Add just the first part of this param, since we will write the file data directly to the Stream
            string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n",
                boundary,
                fileName,
                fileName,
                "application/octet-stream");

            formDataStream.Write(Encoding.ASCII.GetBytes(header), 0, Encoding.ASCII.GetByteCount(header));
            // Write the file data directly to the Stream, rather than serializing it to a string.
            formDataStream.Write(fileBytes, 0, fileBytes.Length);

            // Add the end of the request.  Start with a newline
            string footer = "\r\n--" + boundary + "--\r\n";
            formDataStream.Write(Encoding.ASCII.GetBytes(footer), 0, Encoding.ASCII.GetByteCount(footer));

            // Dump the Stream into a byte[]
            formDataStream.Position = 0;
            byte[] formData = new byte[formDataStream.Length];
            formDataStream.Read(formData, 0, formData.Length);
            formDataStream.Close();

            return formData;
        }

        private static HttpWebResponse PostForm(string postUrl, string contentType, byte[] fileData, string headerkey, string headervalue)
        {
            HttpWebRequest request = WebRequest.Create(postUrl) as HttpWebRequest;

            if (request == null)
            {
                throw new NullReferenceException("request is not a http request");
            }

            // Set up the request properties.
            request.Method = "POST";
            request.ContentType = contentType;
            //request.CookieContainer = new CookieContainer();
            request.ContentLength = fileData.Length;

            //Add header if needed
            request.Headers.Add(headerkey, headervalue);

            // Send the form data to the request.
            using (Stream requestStream = request.GetRequestStream())
            {
                requestStream.Write(fileData, 0, fileData.Length);
                requestStream.Close();
            }
            return request.GetResponse() as HttpWebResponse;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 10:32:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-Post-Import-In-Group-not-working/m-p/2495789#M35918</guid>
      <dc:creator>sachin131</dc:creator>
      <dc:date>2022-05-05T10:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI Post Import In Group not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-Post-Import-In-Group-not-working/m-p/2501396#M35971</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/386310"&gt;@sachin131&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please check if it hit any following limitations, you can find the details in &lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group#limitations" target="_self"&gt;this official documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yingyinr_0-1652084461443.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/711178iEFFDC3801CF2889B/image-size/large?v=v2&amp;amp;px=999" role="button" title="yingyinr_0-1652084461443.png" alt="yingyinr_0-1652084461443.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.ionos.com/digitalguide/websites/website-creation/what-does-the-404-not-found-error-mean/" target="_self"&gt;Error 404: what it means and how to fix it&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 08:26:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-Post-Import-In-Group-not-working/m-p/2501396#M35971</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-09T08:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: PowerBI Post Import In Group not working</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/PowerBI-Post-Import-In-Group-not-working/m-p/2519648#M36141</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/386310"&gt;@sachin131&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Whether your problem has been resolved? If yes, could you please mark the helpful post as &lt;STRONG&gt;Answered&lt;/STRONG&gt;? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 07:29:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/PowerBI-Post-Import-In-Group-not-working/m-p/2519648#M36141</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-17T07:29:59Z</dc:date>
    </item>
  </channel>
</rss>

