<?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: Injecting HttpClient to PowerBIClient in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1721174#M28364</link>
    <description>&lt;P&gt;Hi @Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See if this blog helps:&lt;/P&gt;&lt;P&gt;&lt;A href="https://blog.bennymichielsen.be/2017/11/09/powerbi-with-net-core/" target="_self"&gt;https://blog.bennymichielsen.be/2017/11/09/powerbi-with-net-core/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Liang&lt;BR /&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Mar 2021 02:08:46 GMT</pubDate>
    <dc:creator>V-lianl-msft</dc:creator>
    <dc:date>2021-03-15T02:08:46Z</dc:date>
    <item>
      <title>Injecting HttpClient into PowerBIClient</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1714557#M28310</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm using&amp;nbsp;PowerBIClient in my ASP.NET 5 web application. Currently new instance of&amp;nbsp;PowerBIClient (Microsoft.PowerBI.Api 3.22.0) is made for every request. I've noticed that internally&amp;nbsp;PowerBIClient creates HttpClient and from what I know this is not the best practice. I try to find a way to inject my own HttpClient created with IHttpClientFactory.&amp;nbsp;There is a constructor overload in PowerBIClient that takes HttpClientHandler. Unfortunately I'm not able to get it from IHttpClientFactory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm experimenting with inheritance to access HttpClient property and override it with my own one. It works quite well but ServiceClient&amp;lt;&amp;gt; (which is part of PowerBIClient) creates HttpClient in its primary constructor and I need to dispose it first. Is there any better option?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class PowerBIClientWrapper : PowerBIClient
{
	public PowerBIClientWrapper(
		Uri baseUri,
		ServiceClientCredentials credentials,
		HttpClient httpClient) : base(baseUri, credentials)
	{
		HttpClient?.Dispose();
		FirstMessageHandler = null;
		HttpClientHandler = null;
		HttpClient = httpClient;
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 19:16:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1714557#M28310</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-13T19:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Injecting HttpClient to PowerBIClient</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1721174#M28364</link>
      <description>&lt;P&gt;Hi @Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See if this blog helps:&lt;/P&gt;&lt;P&gt;&lt;A href="https://blog.bennymichielsen.be/2017/11/09/powerbi-with-net-core/" target="_self"&gt;https://blog.bennymichielsen.be/2017/11/09/powerbi-with-net-core/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Liang&lt;BR /&gt;If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 02:08:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1721174#M28364</guid>
      <dc:creator>V-lianl-msft</dc:creator>
      <dc:date>2021-03-15T02:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Injecting HttpClient to PowerBIClient</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1740629#M28563</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;did you find a solution? I am interested in this as well. Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 20:07:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1740629#M28563</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-03-23T20:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Injecting HttpClient into PowerBIClient</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1783068#M28960</link>
      <description>&lt;P&gt;@Anonymous, yes, I found two potential solutions for that. You can either override internal PowerBIClient's HttpClient property or register&amp;nbsp;PowerBIClient as a singleton (with appropirate&amp;nbsp;SocketsHttpHandler configuration). I described both approaches in details on my blog:&amp;nbsp;&lt;A href="https://brokul.dev/powerbiclient-and-socket-exhaustion-in-asp-net-core-app/" target="_self"&gt;https://brokul.dev/powerbiclient-and-socket-exhaustion-in-asp-net-core-app/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 19:22:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Injecting-HttpClient-into-PowerBIClient/m-p/1783068#M28960</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-04-13T19:22:13Z</dc:date>
    </item>
  </channel>
</rss>

