How Mock Server works
vREST provides a base URL (URL depends on project key) Â to your mock APIs. Any incoming request having that base URL is forwarded to vREST Mock Server internally. vREST mock server matches the following attributes in the incoming request with the list of mocks, you have specified in a project:
- Request Method
- Request URL
- Request Parameters
- if required column is ticked, then Mock Server checks whether that parameter exists in the incoming request. And if required column is not ticked, then Mock Server doesn't care about the existence of that parameter.
- if Match Value column is ticked then Mock Server also checks the value of the parameter in the incoming request. And if the value doesn't match, it filter out the specified API mock.
- Request Headers
- if required column is ticked, then Mock Server checks whether that header exists in the incoming request. And if required column is not ticked, then Mock Server doesn't care about the existence of that header.
- if Match Value column is ticked then Mock Server also checks the value of the header in the incoming request. And if the value doesn't match, it filter out the specified API mock.
- Request Raw Body
Â
If the above criteria matches then vREST Mock Server responds with the response provided in "Response Tab" > "Body Sub-tab"Â else it responds an error page with message "Mock request not found." along with reasons, why it doesn't match with the list of API mocks, you have specified.
Producing dynamic responses with Mock Server
Mock Server can be tuned to produce dynamic response with the help of variables. Mock Server receives the variable's value from the following request attributes:
- Request URL
- Request Parameters
And replace the received variable's value in the response body.