Class GraphHttpClient
Graph client that handles transport over http.
Inherited Members
Namespace: Microsoft.Graph.Communications.Common.Transport
Assembly: Microsoft.Graph.Communications.Common.dll
Syntax
public class GraphHttpClient : ObjectRoot, IGraphHttpClient, IGraphClient
Constructors
GraphHttpClient(IGraphLogger, JsonSerializerSettings, HttpClient, Int32, String, ProductInfoHeaderValue, IEnumerable<IGraphProperty>, String)
Initializes a new instance of the GraphHttpClient class.
Declaration
public GraphHttpClient(IGraphLogger logger, JsonSerializerSettings jsonSerializerSettings = null, HttpClient httpClient = null, int numberOfRetries = 3, string correlationIdHeader = null, ProductInfoHeaderValue userAgent = null, IEnumerable<IGraphProperty> defaultProperties = null, string metricName = "PartnerHttpRequests")
Parameters
Type | Name | Description |
---|---|---|
IGraphLogger | logger | The logger. |
Newtonsoft.Json.JsonSerializerSettings | jsonSerializerSettings | The json serializer settings. |
HttpClient | httpClient | The HTTP client. |
Int32 | numberOfRetries | The number of retries. |
String | correlationIdHeader | The correlation identifier header. |
ProductInfoHeaderValue | userAgent | The user agent. |
IEnumerable<IGraphProperty> | defaultProperties | The default properties. |
String | metricName | The metric name. |
Properties
CustomRedirectUriGenerator
Gets or sets the custom redirect URI generator. This is called in case of a redirect (3XX) response from the request. Clients can use this to read the response and give the new redirect url to call in the next request.
Declaration
public Func<HttpResponseMessage, Uri> CustomRedirectUriGenerator { get; set; }
Property Value
Type | Description |
---|---|
Func<HttpResponseMessage, Uri> | The custom redirect URI generator. |
DefaultProperties
Gets the default properties.
Declaration
public IEnumerable<IGraphProperty> DefaultProperties { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IGraphProperty> |
GraphLogger
Gets the graph logger.
Declaration
public IGraphLogger GraphLogger { get; }
Property Value
Type | Description |
---|---|
IGraphLogger |
SerializerSettings
Gets the serializer settings.
Declaration
public JsonSerializerSettings SerializerSettings { get; }
Property Value
Type | Description |
---|---|
Newtonsoft.Json.JsonSerializerSettings |
Methods
Clone(HttpClient)
Clones this instance with optional overrides.
Declaration
public IGraphHttpClient Clone(HttpClient httpClient = null)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | httpClient | The HTTP client to replace the original. |
Returns
Type | Description |
---|---|
IGraphHttpClient | Cloned client with the updated properties. |
InitializeServicePointSettings()
Initializes global service point settings.
Declaration
public static void InitializeServicePointSettings()
LogRequest(TraceLevel, HttpRequestMessage, Object, String, String, Int32)
Logs the request message.
Declaration
protected void LogRequest(TraceLevel level, HttpRequestMessage httpRequest, object content = null, string memberName = null, string filePath = null, int lineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
TraceLevel | level | The level. |
HttpRequestMessage | httpRequest | The http request to log. |
Object | content | The response time. |
String | memberName | Name of the member. |
String | filePath | The file path. |
Int32 | lineNumber | The line number. |
LogResponse(TraceLevel, HttpRequestMessage, Int64, HttpResponseMessage, Object, Exception, String, String, Int32)
Logs the response message.
Declaration
protected void LogResponse(TraceLevel level, HttpRequestMessage httpRequest, long responseTime, HttpResponseMessage httpResponse = null, object content = null, Exception exception = null, string memberName = null, string filePath = null, int lineNumber = 0)
Parameters
Type | Name | Description |
---|---|---|
TraceLevel | level | The level. |
HttpRequestMessage | httpRequest | The http request to log. |
Int64 | responseTime | The response time. |
HttpResponseMessage | httpResponse | The http response to log. |
Object | content | The content to log. |
Exception | exception | The exception to log. |
String | memberName | Name of the member. |
String | filePath | The file path. |
Int32 | lineNumber | The line number. |
SendAsync<T>(IGraphRequest<T>, CancellationToken)
Declaration
public Task<IGraphResponse> SendAsync<T>(IGraphRequest<T> graphRequest, CancellationToken cancellationToken = default(CancellationToken))
where T : class
Parameters
Type | Name | Description |
---|---|---|
IGraphRequest<T> | graphRequest | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IGraphResponse> |
Type Parameters
Name | Description |
---|---|
T |
SendAsync<T1, T2>(IGraphRequest<T1>, CancellationToken)
Declaration
public Task<IGraphResponse<T2>> SendAsync<T1, T2>(IGraphRequest<T1> graphRequest, CancellationToken cancellationToken = default(CancellationToken))
where T1 : class where T2 : class
Parameters
Type | Name | Description |
---|---|---|
IGraphRequest<T1> | graphRequest | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IGraphResponse<T2>> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 |
SendHttpRequestAsync<T1, T2>(IGraphRequest<T1>, CancellationToken)
Sends the request asynchronously. We only retry if the Http request fails with an exception. We do not retry in case of error response returned from the request.
Declaration
protected virtual Task<IGraphResponse<T2>> SendHttpRequestAsync<T1, T2>(IGraphRequest<T1> graphRequest, CancellationToken cancellationToken)
where T1 : class where T2 : class
Parameters
Type | Name | Description |
---|---|---|
IGraphRequest<T1> | graphRequest | The request to be sent out. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<IGraphResponse<T2>> | HttpResponseMessage received for the |
Type Parameters
Name | Description |
---|---|
T1 | Type of the content present in the request. |
T2 | Type of the expected content in response. |
SendRawHttpRequestAsync(HttpRequestMessage, CancellationToken)
Send a Http request as an asynchronous operation. The content sent using this is not parsed or logged.
Declaration
public Task<HttpResponseMessage> SendRawHttpRequestAsync(HttpRequestMessage httpRequest, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
HttpRequestMessage | httpRequest | The http request message to send. |
CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
Task<HttpResponseMessage> | The task object representing the asynchronous operation. |