Simulate HTTP Status codes — 400, 404, 500, etc using Requestly
This article explains how to use Requestly to simulate different API status codes and test your app.
Requestly Browser Extension can simulate different status codes on an API by redirecting the actual API to a mock API.
The mock API simulating the desired status code is hit instead of the actual API. It is done using the redirect rule of requestly.
Create a mock API using Requestly
Requestly has a Mock Server capability to create a Mock API response.
- Create a new mock API here- https://app.requestly.io/mock-server/viewer/create
- Set the status code you want to simulate.
- A mock Simulating 500 status code- https://app.requestly.io/mock/7gmdFoaQdhKfe28uLfa9
Requestly mock server handles the CORS headers automatically so that the browser does not block the cross-origin requests.
Redirecting the actual API endpoint to the Mock Server endpoint.
Removing Content-Security-Policy Headers
You can use the Requestly marketplace rule to bypass this, which is a prebuilt rule to remove the
I hope this empowers you to do robust testing of your frontend by simulating different API behaviours.
This feature will soon be available on the desktop app. Stay Tuned.
Originally published at https://requestly.io.