Share via


IDownstreamApi.CallApiAsync Method

Definition

Overloads

CallApiAsync(DownstreamApiOptions, ClaimsPrincipal, HttpContent, CancellationToken)

Calls the downstream API based on a programmatic description of the downstream API. The choice of calling the API on behalf of the user or the app, is made using RequestAppToken.

CallApiAsync(String, Action<DownstreamApiOptions>, ClaimsPrincipal, HttpContent, CancellationToken)

Calls the downstream API based on a description of the downstream API in the configuration (service name), overridatable programmatically. The choice of calling the API on behalf of the user or the app, is made by the configuration or programmatically. This is the lowest level API. There are other APIs for specific Http methods.

CallApiAsync(DownstreamApiOptions, ClaimsPrincipal, HttpContent, CancellationToken)

Calls the downstream API based on a programmatic description of the downstream API. The choice of calling the API on behalf of the user or the app, is made using RequestAppToken.

public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> CallApiAsync (Microsoft.Identity.Abstractions.DownstreamApiOptions downstreamApiOptions, System.Security.Claims.ClaimsPrincipal? user = default, System.Net.Http.HttpContent? content = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CallApiAsync : Microsoft.Identity.Abstractions.DownstreamApiOptions * System.Security.Claims.ClaimsPrincipal * System.Net.Http.HttpContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function CallApiAsync (downstreamApiOptions As DownstreamApiOptions, Optional user As ClaimsPrincipal = Nothing, Optional content As HttpContent = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of HttpResponseMessage)

Parameters

downstreamApiOptions
DownstreamApiOptions

Options.

user
ClaimsPrincipal

(Optional) Claims representing a user. This is useful on platforms like Blazor or Azure Signal R, where the HttpContext is not available. In other platforms, the library will find the user from the HTTP request context.

content
HttpContent

Content to send to the API in the case where HttpMethod is HttpMethod.Patch, Post, Put.

cancellationToken
CancellationToken

Cancellation token.

Returns

An HttpResponseMessage that the application will process.

Applies to

CallApiAsync(String, Action<DownstreamApiOptions>, ClaimsPrincipal, HttpContent, CancellationToken)

Calls the downstream API based on a description of the downstream API in the configuration (service name), overridatable programmatically. The choice of calling the API on behalf of the user or the app, is made by the configuration or programmatically. This is the lowest level API. There are other APIs for specific Http methods.

public System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> CallApiAsync (string? serviceName, Action<Microsoft.Identity.Abstractions.DownstreamApiOptions>? downstreamApiOptionsOverride = default, System.Security.Claims.ClaimsPrincipal? user = default, System.Net.Http.HttpContent? content = default, System.Threading.CancellationToken cancellationToken = default);
abstract member CallApiAsync : string * Action<Microsoft.Identity.Abstractions.DownstreamApiOptions> * System.Security.Claims.ClaimsPrincipal * System.Net.Http.HttpContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
Public Function CallApiAsync (serviceName As String, Optional downstreamApiOptionsOverride As Action(Of DownstreamApiOptions) = Nothing, Optional user As ClaimsPrincipal = Nothing, Optional content As HttpContent = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of HttpResponseMessage)

Parameters

serviceName
String

Name of the service describing the downstream web API. There can be several configuration named sections mapped to a DownstreamApiOptions, each for one downstream API. You can pass-in null, but in that case downstreamApiOptionsOverride needs to be set.

downstreamApiOptionsOverride
Action<DownstreamApiOptions>

(Optional) Overrides the options proposed in the configuration described by serviceName. Can be null, in which case only the configuration is applied.

user
ClaimsPrincipal

(Optional) Claims representing a user. This is useful on platforms like Blazor or Azure Signal R, where the HttpContext is not available. In other platforms, the library will find the user from the HTTP request context.

content
HttpContent

Content to send to the API in the case where HttpMethod is HttpMethod.Patch, Post, Put.

cancellationToken
CancellationToken

Cancellation token.

Returns

An HttpResponseMessage that the application will process.

Applies to