AadHttpClient class

AadHttpClient is used to perform REST calls against an Azure AD Application.

Remarks

This class is marked as @sealed. Subclasses should not extend it.

For communicating with SharePoint, use the SPHttpClient class instead. For communicating with Microsoft Graph, use the MSGraphClient class.

Constructors

(constructor)(serviceScope, resourceEndpoint, options)

Constructs a new instance of the AadHttpClient class

Properties

configurations

The standard predefined AadHttpClientConfiguration objects for use with the AadHttpClient class.

Methods

fetch(url, configuration, options)

Performs a REST service call.

get(url, configuration, options)

Calls fetch(), but sets the method to "GET".

post(url, configuration, options)

Calls fetch(), but sets the method to "POST".

Constructor Details

(constructor)(serviceScope, resourceEndpoint, options)

Constructs a new instance of the AadHttpClient class

constructor(serviceScope: ServiceScope, resourceEndpoint: string, options?: IAadHttpClientOptions);

Parameters

serviceScope
ServiceScope

The service scope is needed to retrieve some of the class's internal components.

resourceEndpoint

string

options
IAadHttpClientOptions

Configuration options for the request to get an access token.

Property Details

configurations

The standard predefined AadHttpClientConfiguration objects for use with the AadHttpClient class.

static readonly configurations: IAadHttpClientConfigurations;

Property Value

Method Details

fetch(url, configuration, options)

Performs a REST service call.

fetch(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions): Promise<HttpClientResponse>;

Parameters

url

string

The endpoint URL that fetch will be called on.

configuration
@microsoft/sp-http!default:class

Determines the default behavior of HttpClient; normally this should be the latest version number from HttpClientConfigurations.

options
IHttpClientOptions

Additional options that affect the request.

Returns

!Promise:class<@microsoft/sp-http!default:class>

A promise that will return the result.

Remarks

Although the AadHttpClient subclass adds additional enhancements, the parameters and semantics for HttpClient.fetch() are essentially the same as the WHATWG API standard that is documented here: https://fetch.spec.whatwg.org/

get(url, configuration, options)

Calls fetch(), but sets the method to "GET".

get(url: string, configuration: AadHttpClientConfiguration, options?: IHttpClientOptions): Promise<HttpClientResponse>;

Parameters

url

string

The endpoint URL that fetch will be called on.

configuration
@microsoft/sp-http!default:class

Determines the default behavior of HttpClient; normally this should be the latest version number from HttpClientConfigurations.

options
IHttpClientOptions

Additional options that affect the request.

Returns

!Promise:class<@microsoft/sp-http!default:class>

A promise that will return the result.

post(url, configuration, options)

Calls fetch(), but sets the method to "POST".

post(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions): Promise<HttpClientResponse>;

Parameters

url

string

The endpoint URL that fetch will be called on.

configuration
@microsoft/sp-http!default:class

Determines the default behavior of HttpClient; normally this should be the latest version number from HttpClientConfigurations.

options
IHttpClientOptions

Additional options that affect the request.

Returns

!Promise:class<@microsoft/sp-http!default:class>

A promise that will return the result.