Reputation: 2471
I'm using the Microsoft.Graph
SDK in my ASP.NET Core project, and want to take advantage of .NET Core's HttpClient
management via IHttpClientFactory
.
I see that GraphServiceClient
accepts a HttpClient
parameter in its constructor, allowing me to pass in an injected HttpClient
directly. It seems to be working fine.
But I did notice the constructor's documentation says:
The System.Net.Http.HttpClient to use for making requests to Microsoft Graph. Use the Microsoft.Graph.GraphClientFactory to get a pre-configured HttpClient that is optimized for use with the Microsoft Graph service API
The typed HttpClient
instance I'm injecting in is the default one created by .NET Core's IHttpClientFactory
. Does it need some extra configuration to be "optimized" for use with the Graph SDK?
Upvotes: 0
Views: 937
Reputation: 20778
The HttpClient
created by GraphClientFactory
has BaseAddress
set to
https://graph.microsoft.com/v1.0/
With the following DefaultRequestHeaders
SdkVersion: xxx
FeatureFlag: xxx
Cache-Control: no-store, no-cache
MaxResponseContentBufferSize
is set to 2147483647
and Timeout
is set to 00:01:40
.
It should not be complicated to set up HttpClient
for Graph API manually.
Upvotes: 1