Query Parameters
This section describes matcher functions designed to target and match query parameters in incoming HTTP requests.
query_param
Specifies a required query parameter for the request. This function ensures that the specified query parameter (key-value pair) must be included in the request URL for the mock server to respond.
Note: The request query keys and values are implicitly allowed but not required to be URL-encoded. However, the value passed to this method should always be in plain text (i.e., not encoded).
Parameters
name
: The name of the query parameter to match against.value
: The expected value of the query parameter.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_not
This function ensures that the specified query parameter (key) does exist in the request URL, and its value is not equal to the specified value.
Note: Query keys and values are implicitly allowed but not required to be URL-encoded in the HTTP request. However, values passed to this method should always be in plain text (i.e., not encoded).
Parameters
name
: The name of the query parameter to ensure is not present.value
: The value of the query parameter to ensure is not present.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_exists
Specifies that a query parameter must be present in an HTTP request. This function ensures that the specified query parameter key exists in the request URL for the mock server to respond, regardless of the parameter’s value.
Note: The query key in the request is implicitly allowed but not required to be URL-encoded. However, provide the key in plain text here (i.e., not encoded).
Parameters
name
: The name of the query parameter that must exist in the request.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_missing
Specifies that a query parameter must not be present in an HTTP request. This function ensures that the specified query parameter key is absent in the request URL for the mock server to respond, regardless of the parameter’s value.
Note: The request query key is implicitly allowed but not required to be URL-encoded. However, provide the key in plain text (i.e., not encoded).
Parameters
name
: The name of the query parameter that should be missing from the request.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_includes
Specifies that a query parameter’s value (not the key) must contain a specific substring for the request to match. This function ensures that the specified query parameter (key) does exist in the request URL, and it does have a value containing the given substring for the mock server to respond.
Note: The request query key-value pairs are implicitly allowed but not required to be URL-encoded. However, provide the substring in plain text (i.e., not encoded).
Parameters
name
: The name of the query parameter to match against.substring
: The substring that must appear within the value of the query parameter.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_excludes
Specifies that a query parameter’s value (not the key) must not contain a specific substring for the request to match.
This function ensures that the specified query parameter (key) does exist in the request URL, and it does not have a value containing the given substring for the mock server to respond.
Note: The request query key-value pairs are implicitly allowed but not required to be URL-encoded. However, provide the substring in plain text here (i.e., not encoded).
Parameters
name
: The name of the query parameter to match against.substring
: The substring that must not appear within the value of the query parameter.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_prefix
Specifies that a query parameter’s value (not the key) must start with a specific prefix for the request to match. This function ensures that the specified query parameter (key) has a value starting with the given prefix in the request URL for the mock server to respond.
Note: The request query key-value pairs are implicitly allowed but not required to be URL-encoded. Provide the prefix in plain text here (i.e., not encoded).
Parameters
name
: The name of the query parameter to match against.prefix
: The prefix that the query parameter value should start with.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_prefix_not
Specifies that a query parameter’s value (not the key) must not start with a specific prefix for the request to match. This function ensures that the specified query parameter (key) has a value not starting with the given prefix in the request URL for the mock server to respond.
Note: The request query key-value pairs are implicitly allowed but not required to be URL-encoded. Provide the prefix in plain text here (i.e., not encoded).
Parameters
name
: The name of the query parameter to match against.prefix
: The prefix that the query parameter value should not start with.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_suffix
Specifies that a query parameter’s value (not the key) must end with a specific suffix for the request to match. This function ensures that the specified query parameter (key) has a value ending with the given suffix in the request URL for the mock server to respond.
Note: The request query key-value pairs are implicitly allowed but not required to be URL-encoded. Provide the suffix in plain text here (i.e., not encoded).
Parameters
name
: The name of the query parameter to match against.suffix
: The suffix that the query parameter value should end with.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_suffix_not
Specifies that a query parameter’s value (not the key) must not end with a specific suffix for the request to match. This function ensures that the specified query parameter (key) has a value not ending with the given suffix in the request URL for the mock server to respond.
Note: The request query key-value pairs are implicitly allowed but not required to be URL-encoded. Provide the suffix in plain text here (i.e., not encoded).
Parameters
name
: The name of the query parameter to match against.suffix
: The suffix that the query parameter value should not end with.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_matches
Specifies that a query parameter must match a specific regular expression pattern for the key and another pattern for the value. This function ensures that the specified query parameter key-value pair matches the given patterns in the request URL for the mock server to respond.
Parameters
key_regex
: A regular expression pattern for the query parameter’s key to match against.value_regex
: A regular expression pattern for the query parameter’s value to match against.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.
query_param_count
Specifies that the count of query parameters with keys and values matching specific regular expression patterns must equal a specified number for the request to match. This function ensures that the number of query parameters whose keys and values match the given regex patterns is equal to the specified count in the request URL for the mock server to respond.
Parameters
key_regex
: A regular expression pattern for the query parameter’s key to match against.value_regex
: A regular expression pattern for the query parameter’s value to match against.expected_count
: The expected number of query parameters whose keys and values match the regex patterns.
Example
Returns
The updated When
instance to allow method chaining for additional configuration.