Table of Contents

Class ParameterizedEndpoint<TParameters>

Namespace
CSF.Screenplay.WebApis
Assembly
CSF.Screenplay.WebApis.dll

Base type for a Web API endpoint which has a strongly-typed request payload but which is not expected to return a response body.

public abstract class ParameterizedEndpoint<TParameters> : EndpointBase, IHasName

Type Parameters

TParameters

The type of the parameters object which is required to create an HTTP request message

Inheritance
ParameterizedEndpoint<TParameters>
Implements
Derived
JsonEndpoint<TParameters>
Inherited Members

Remarks

There are several concrete types of endpoint available, all of which derive from EndpointBase, for more information about the purpose of endpoints and how they are used, see the documentation for that base type.

Developers are welcome to create specialized derived types based upon this or other subclasses of EndpointBase if they have specific needs. Derived classes should overrideGetHttpRequestMessageBuilder(TParameters) with a method that calls the base implementation and then further manipulates the message builder before returning it. This particular class may only be used as a base type for specialized implementations. Implementing types must provide an implementation of GetHttpRequestMessageBuilder(TParameters) which includes whatever logic is required to serialize the parameters value into the HTTP request. For an example implementation which serializes the parameters as a JSON string, see JsonEndpoint<TParameters>.

When deriving from this class, developers are strongly encouraged to set the Name property to a human-readable name for this endpoint. This will improve the readability of reports.

For more information, see the documentation article for using web APIs.

Constructors

ParameterizedEndpoint(string, HttpMethod)

Initializes a new instance of ParameterizedEndpoint<TParameters> with a relative URI and an optional HTTP method.

protected ParameterizedEndpoint(string relativeUri, HttpMethod method = null)

Parameters

relativeUri string

A relative URI string for the current endpoint.

method HttpMethod

An optional HTTP method.

Remarks

When setting the relative URI, avoid a leading forward-slash. Prefer myApp/doSomething over /myApp/doSomething.

If you omit the HTTP method, then the created builder will also not specify an HTTP method, which (if used to generate a request) will result in an HTTP GET request. See CreateRequestMessage().

ParameterizedEndpoint(Uri, HttpMethod)

Initializes a new instance of ParameterizedEndpoint<TParameters> with a URI and an optional HTTP method.

protected ParameterizedEndpoint(Uri uri, HttpMethod method = null)

Parameters

uri Uri

A URI for the current endpoint; this may be relative or absolute.

method HttpMethod

An optional HTTP method.

Remarks

If you omit the HTTP method, then the created builder will also not specify an HTTP method, which (if used to generate a request) will result in an HTTP GET request. See CreateRequestMessage().

Methods

GetHttpRequestMessageBuilder(TParameters)

Gets a HttpRequestMessageBuilder from the state of the current instance and the specified parameters value.

public abstract HttpRequestMessageBuilder GetHttpRequestMessageBuilder(TParameters parameters)

Parameters

parameters TParameters

The parameters required to create an HTTP request builder

Returns

HttpRequestMessageBuilder

An HTTP request message builder

Remarks

When overriding/implementing this method use GetBaseHttpRequestMessageBuilder() to get a builder from the base class. You should then further customize that builder instance according to the appropriate logic for this implementation, such as to add the parameter value.

See Also

EndpointBase
Endpoint
Endpoint<TResult>
ParameterizedEndpoint<TParameters, TResponse>
JsonEndpoint<TParameters>
JsonEndpoint<TParameters, TResult>