Skip to content

AddHeader

Adds a new HTTP header to the request.

1
myRestRequest.AddHeader(name: string, value: string):RestRequest

Parameters

string name
    The name of the HTTP header.

string value
    The value of the HTTP header.

Returns

The current RestRequest instance.

Remarks

The name and value arguments are required. Otherwise, an error is thrown.

Example

1
2
3
4
5
var client = $Rest.Create('https://login.microsoftonline.com/tenant/oauth2/v2.0/token');
var request = client.Request();

request.AddHeader('Content-Type', 'application/x-www-form-urlencoded');
request.AddHeader('Host', 'login.microsoftonline.com');

See Also