This article will take you through how to use Requestly to simulate fake 404, 500 response status codes and test your frontend app
without changing anything in your codebase. There are two possible ways to solve this using Requestly:
If you want to simulate a different status code for network traffic in Android apps, use our Android Debugger
Using Desktop App
You can use any MITM proxy to intercept the request and simulate the status code. However, using Requestly Desktop App, it is possible in a single step.
- Go to Rules Tab and Click on New Rule
- Select Modify Response
- Define the exact URL (or Pattern) and define the status code. That's it.
Here's a step by step video demo explaning same.
Download Requestly Desktop App from here
Using Browser Extension
Requestly Browser Extension can simulate different status codes on an API by redirecting the actual API to a mock API using Requestly's
1. Create a mock API using Requestly
Requestly has a Mock Server capability to create a Mock API response. Here are the steps to create one.
- Create a new mock API here- https://app.requestly.io/mock-server/viewer/create
- Set the status code you want to simulate (404, 500 ...).
Example mock Simulating 500 status code- https://app.requestly.io/mock/aIfQd7toGFUMCL0PZDrc
Requestly mock server handles the CORS headers automatically so that the browser does not block the cross-origin requests.
2. Redirecting actual API endpoint to the Mock Server endpoint.
- Setup a redirect rule to redirect the actual API to the requestly mock API.
Redirecting Blinkit Search API to a mock API simulating 404 status code
3. Removing Content-Security-Policy Headers
You can use the Requestly marketplace rule to bypass this, which has a prebuilt rule to remove the
content-security-policy header. Thats it.
Download Requestly browser extension from here
I hope this empowers you to do robust testing of your frontend app/website by simulating different API behaviours.