Table of Contents

Class Endpoint<TResult>

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

A Web API endpoint which has no expected request payload and which is expected to return a response body that exposes a strongly-typed object.

public class Endpoint<TResult> : EndpointBase, IHasName

Type Parameters

TResult

The type of object which is expected to be exposed by the HTTP response content

Inheritance
Endpoint<TResult>
Implements
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.

The manner in which this endpoint exposes the strongly typed response object is undefined within the endpoint itself. It is down to a performable implementation to deserialize the result object from the HTTP response content.

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() with a method that calls the base implementation and then further manipulates the message builder before returning it.

When using or 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

Endpoint(string, HttpMethod)

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

public Endpoint(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().

Endpoint(Uri, HttpMethod)

Initializes a new instance of Endpoint<TResult> with a URI and an optional HTTP method.

public Endpoint(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()

Gets a HttpRequestMessageBuilder from the state of the current instance.

public virtual HttpRequestMessageBuilder<TResult> GetHttpRequestMessageBuilder()

Returns

HttpRequestMessageBuilder<TResult>

An HTTP request message builder

See Also

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