Find out answers to questions related to API mocking using QuickMocker (multiple methods, RegExp in the URL path, dynamic properties or shortcodes etc.)
Yes, we support multiple request HTTP methods (e.g. GET/HEAD etc.) per endpoint. If endpoint has multiple methods, it will get label of the first method plus amount of other method (e.g. GET + 2) and will be marked with a dashed border like on the image below:
With the RegExp URL Path you can intercept requests using Regular Expressions (or so called search patterns). What does this mean? It means instead of creating multiple endpoints with a static URL path, you can define just one single endpoint that matches the required search pattern.
For instance, imagine you have an endpoint where you need to get user object, e.g. 'GET /user/‹id›'. In order to get multiple users with different IDs, you would have to define multiple endpoints with URL Path like 'user/1', 'user/2' and so on.
Using RegExp URL Path you can define one endpoint with the following path: '^user/[0-9]+$'. This URL Path will allow you to intercept any user ID.
After you create new Project our system automatically generates one RegExp endpoint for you, which intercepts all the
You may read more about regular expressions on Wikipedia.
Please note that RexExp URL path that does not have start (^) and end ($) symbols, will match the request URI at any position. E.g. if you set URL path for your endpoint to "mocker" and after that you send request to "/some-url/mocker/test" or to "/i-got-some-mocker-here", all of them will be intercepted by this endpoint. Same as you would send request just to "/mocker".
After you create a new endpoint, we automatically generate a default endpoint which intercepts all the requests to your URL and responds with the 404 status code. It looks like on the screenshot below:
Because of this any request to your project (including unexisting) will be logged. Keep this endpoint at the bottom of your endpoints list so it has the least of priority. This means it will be triggered only in case there was no other matching endpoint.
Please note: in case you remove or disable this endpoint, you won't be able to debug requests that do not match any method name / URL Path among the endpoints you defined and therefore it will be more difficult to fix your incorrect requests. Thus we recommend you to always keep this endpoint enabled in the list.
In order to make your mock endpoint look and work more dynamic, you may find useful some of our shortcodes (dynamic response properties). This will allow you to make each response unique with its own data depending on the context like URL path or current date/time. Additionally it can generate unique or random values.
Currently we support following shortcodes:
See example below:
URL Path (RegExp turned on):
Requesting following endpoint using following Method/URL:
Can produce the following response body:
Allows you to forward request you receive to your endpoint to any other URL including your local web server URL or IP address. This way you can process requests from the 3-rd parties on your development machines. This could be very handy while you develop integration with the 3-rd party web service using webhooks, which means you need to receive request from 3-rd party to your application, but you currently do not have a public (available on the Internet) URL. QuickMocker can receive this request, because it does provide you with a public URL and it can forward this request to your local application URL, which allows you to debug your code locally on your own machine during the incoming external request.
Please note that QuickMocker's Local Forwarder is working on the browser level, which means it can forward request to your app only when your Project's Reuqets Log tab is turned on. See picture below:
You can also view response from your local app in the request log record along with usual request and response in the Forwarder Response tab. See image below:
Warning! By default your browser will block requests to your app URL in case you use HTTP (non-HTTPS) protocol (you can read more this behavior here). Please disable this security feature in your browser for QuickMocker site if you want to use Local Forwarder feature with your non-HTTPS URL. For instance in Chrome you need to allow Insecure Content inside QuickMocker site settings. For all the rest browsers please read through the following article.