Search code examples
apimockingmiddlemaninterceptrequestly

Requestly chrome extension mock api response to 503


I want to change HTTP Status Code to 503 with a custom response body on URL ending with .mpd. I am using Requestly chrome extension to intercept the request and have it failed with 503.

Here is the Modify API Response rule screenshot

rule

Here's Requestly logs in devtools which shows that request was correctly intercepted. requestly tab

The rule looks like it kicks in but is not showing the correct response code. Looking at the network tab it looks like the interception did not work

enter image description here

Need help with mocking the status code to 503 and custom response body.


Solution

  • HTTP Status Code can not be changed by Chrome Extension. Chrome doesn't provide any APIs which allow Chrome Extensions to change the status code.

    You should be able to solve this problem using the Requestly desktop app where you can also specify the status code while defining your mocked API response.

    enter image description here

    A desktop app-based solution is more reliable however if you really want to work with Chrome extension only. Here's a workaround that you can try

    1. Setup a new API Mock with 503 Status Code and the Response Body
    2. Setup a new Redirect Rule to redirect your actual URL to the Mock URL

    More details are covered in this SO answer

    References