Skip to content

A response you asked for was refused

A request that asks for one of a mock’s responses with X-MockHub-Response gets one of two answers instead of a response:

{
"type": "https://mockhub.dev/problems/response-selection-unavailable",
"title": "Response cannot be selected",
"status": 422,
"detail": "The response named in X-MockHub-Response cannot be served for this request. Check that its mock is active, matches the request and allows request overrides."
}
{
"type": "https://mockhub.dev/problems/response-selector-malformed",
"title": "Malformed response selector",
"status": 400,
"detail": "The X-MockHub-Response header must hold one value of the form <mock reference>:<response key>, as the mock's editor copies it."
}

MockHub refuses rather than answer the mock’s default, so a test that wanted a particular response cannot pass on another. The 422 is one answer for every reason, so to find the reason, open the request under Request logs and select Check matching. It names the first cause below that holds for the named mock, as the mock is now.

The header is not in the form MockHub reads (400)

Section titled “The header is not in the form MockHub reads (400)”

The answer is the 400. The header must be one value, <mock reference>:<response key>, the mock reference being the last 12 characters of the mock’s identifier; a whole identifier is refused.

  1. Copy it from the mock’s editor instead of writing it: open Use this response in a request and select Copy header.
  2. Check that the client sends it once. A client, a proxy or a test library that adds a second copy produces the 400.

An inactive mock answers nothing, with a header or without one. Check matching says it is inactive; in the editor, How this mock responds reads Inactive.

  1. Open the mock and set its Status to Active, or select Save and activate.
  2. Send the request again.

The header does not choose the mock: the mock the request matches does. If the mock named in the header is not the one the method, path and other rules find, the request is refused. Check matching replays the logged request against the named mock and says what differs.

  1. Fix the request, or the mock’s rules under Which requests it answers.
  2. See My request returns 404 for the rules that fail most often, and for a scenario state or data store record the mock waits for.

A response was deleted, or the key was copied from another mock. Check matching lists the keys the mock has now.

  1. Open the mock and its response, and copy the header again under Use this response in a request.

The mock does not allow requests to ask for a response

Section titled “The mock does not allow requests to ask for a response”

Under How a response is chosen, A request may ask for another response is off.

  1. Turn it on and select Save mock, or send the request without the header.

A sequence takes no override: each call gets the next step. Call it without the header, or ask a mock that has a default response; see Return a sequence of responses.

The reference belongs to another mock or project

Section titled “The reference belongs to another mock or project”

The header holds the reference of another mock, or of a mock in another project. A copy of a mock has an identifier, and so a reference, of its own, so the header copied from the original does not work on the copy.

  1. Copy the header from the mock the request is meant for.

In the editor, Try it with Which response a request gets asks the saved mock which response a request would get, and shows the same refusal, without a request to the project’s address. It tests this mock alone, so a competing mock is not part of the answer; a request to the project’s address is the real thing.

Report a problem with the time of the request, its method and URL, and the name of the mock you meant.

Report a problem with this page