Table of Contents

Class JsonEndpoint<TParameters>

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

Base type for a Web API endpoint which accepts a request payload in the form of a strongly typed object serialized to JSON string, but which is not expected to return a response body.

public class JsonEndpoint<TParameters> : ParameterizedEndpoint<TParameters>, IHasName

Type Parameters

TParameters

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

Inheritance
JsonEndpoint<TParameters>
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.

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.

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

JsonEndpoint(string, HttpMethod)

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

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

JsonEndpoint(Uri, HttpMethod)

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

public JsonEndpoint(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 override HttpRequestMessageBuilder GetHttpRequestMessageBuilder(TParameters parameters)

Parameters

parameters TParameters

The parameters required to create an HTTP request builder

Returns

HttpRequestMessageBuilder

An HTTP request message builder

Remarks

This method serializes the parameters value into a JSON string and sets it into the HTTP request content: Content.

See Also

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