-
Notifications
You must be signed in to change notification settings - Fork 2
Actions
StoryLine.Rest library at the moment includes only HttpRequest action which provide fluent syntax simplifying HTTP request definition. HttpRequest action provide the following major configuration options:
- Service() refers to service base address registered in test configuration.
- Method() specifies HTTP methods used by request.
- Url() specifies relative (or absolute) address. This string should also include query string.
- QueryParam() specifies query parameter appended to add to url.
- Header() addess HTTP request header to collection of request headers.
- Body() defines content sent with request.
Method is used to refer to endpoint registered in configuration of StoryLine.Rest library. If only one endpoint is registered this method may not be called. Library will automatically treat the only registered endpoint as default one.
Method defines HTTP method used by request. This method is accept one of the following values: HEAD, GET, POST, PUT, DELETE. Values are not case sensitive but it's recommended to use upper case strings.
Method specifies relative or absolute url of request. Url may also include query string. Here are valid examples of input values:
http://mysite.com/page1?query=a
/page1?query=a
NOTE: If QueryParam() is used parameters are added to value of Url().
Methods adds query string parameter to collection of parameters used to construct request url. If this method is called multiple times all provided values are added to query string. Provided parameters included using UrlEncode() method.
NOTE: If QueryParam() is used parameters are added to value of Url().
This method allows to add header to request. If method is called multiple times multiple headers are added to request.
NOTE: Content-Length header is not supported.
This method allows to specify content sent to with request (e.g POST, PUT) methods. Content is defined as array of bytes. In order support frequent use cases the following extension methods are supported:
-
JsonBody()defines content asstringwhich contains JSON data. -
JsonObjectBody()allows to define request as .NET object which is serialized to JSON. Default serialization settings are controlled by the following configuration property. -
TextBody()defines body as string provided to this method. -
FormUrlEncodedBody()allows to define body as key-value collection which is formatted as x-www-form-urlencoded content type.