Partilhar via


DownstreamWebApiGenericExtensions.PostForUserAsync<TOutput,TInput> Method

Definition

Caution

Use IDownstreamApi.PostForUserAsync in Microsoft.Identity.Abstractions, implemented in Microsoft.Identity.Web.DownstreamApi.See aka.ms/id-web-downstream-api-v2 for migration details.

Calls the web API with an HttpPost, providing strongly typed input and getting strongly typed output.

[System.Obsolete("Use IDownstreamApi.PostForUserAsync in Microsoft.Identity.Abstractions, implemented in Microsoft.Identity.Web.DownstreamApi.See aka.ms/id-web-downstream-api-v2 for migration details.", false)]
public static System.Threading.Tasks.Task<TOutput?> PostForUserAsync<TOutput,TInput> (this Microsoft.Identity.Web.IDownstreamWebApi downstreamWebApi, string serviceName, string relativePath, TInput inputData, Action<Microsoft.Identity.Web.DownstreamWebApiOptions>? downstreamWebApiOptionsOverride = default, System.Security.Claims.ClaimsPrincipal? user = default, string? authenticationScheme = default) where TOutput : class;
[<System.Obsolete("Use IDownstreamApi.PostForUserAsync in Microsoft.Identity.Abstractions, implemented in Microsoft.Identity.Web.DownstreamApi.See aka.ms/id-web-downstream-api-v2 for migration details.", false)>]
static member PostForUserAsync : Microsoft.Identity.Web.IDownstreamWebApi * string * string * 'Input * Action<Microsoft.Identity.Web.DownstreamWebApiOptions> * System.Security.Claims.ClaimsPrincipal * string -> System.Threading.Tasks.Task<'Output (requires 'Output : null)> (requires 'Output : null)
<Extension()>
Public Function PostForUserAsync(Of TOutput As Class, TInput As Class) (downstreamWebApi As IDownstreamWebApi, serviceName As String, relativePath As String, inputData As TInput, Optional downstreamWebApiOptionsOverride As Action(Of DownstreamWebApiOptions) = Nothing, Optional user As ClaimsPrincipal = Nothing, Optional authenticationScheme As String = Nothing) As Task(Of TOutput)

Type Parameters

TOutput

Output type.

TInput

Input type.

Parameters

downstreamWebApi
IDownstreamWebApi

The downstream web API.

serviceName
String

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

relativePath
String

Path to the API endpoint relative to the base URL specified in the configuration.

inputData
TInput

Input data sent to the API.

downstreamWebApiOptionsOverride
Action<DownstreamWebApiOptions>

Overrides the options proposed in the configuration described by serviceName.

user
ClaimsPrincipal

[Optional] Claims representing a user. This is useful in platforms like Blazor or Azure Signal R, where the HttpContext is not available. In other platforms, the library will find the user from the HttpContext.

authenticationScheme
String

Authentication scheme. If null, will use OpenIdConnectDefault.AuthenticationScheme if called from a web app, and JwtBearerDefault.AuthenticationScheme if called from a web API.

Returns

Task<TOutput>

A strongly typed response from the web API.

Attributes

Applies to