Skip to content

AddDefaultParameter

Adds a default parameter to all requests made by this client.

1
myRestClient.AddDefaultParameter(name: string, value: any, type?: ( "Cookie" | "GetOrPost" | "UrlSegment" | "HttpHeader" | "RequestBody" | "QueryString" | "QueryStringWithoutEncode" )):RestClient

Parameters

string name
    The name of the parameter.

any value
    The value of the parameter.

( "Cookie" | "GetOrPost" | "UrlSegment" | "HttpHeader" | "RequestBody" | "QueryString" | "QueryStringWithoutEncode" ) type optional
    The type of the parameter. See RestRequest.AddParameter.

Returns

The current RestClient instance.

Examples

Send an API version with every request

1
2
var client = $Rest.Create('https://api.example.com/')
    .AddDefaultParameter('api-version', '2024-01-01', 'QueryString');

See Also