How to modify response status code in charles proxy 

Introduction

In Charles Proxy, the Modify Response Status Code tool lets you change or simulate different response status codes in HTTP responses. However, setting this up can be complex and time-consuming. You need to configure the proxy settings, ensure the SSL certificate is installed, and create rules to modify response status codes. This adds complexity and requires multiple steps before you can even start testing.

Now, imagine achieving the same result with just a couple of clicks. Requestly’s Chrome extension offers a streamlined solution, letting you modify response status codes directly from your browser without a complex setup. No proxy configuration or SSL certificate is required.

How to Configure Charles Proxy’s Rewrite Tool to Modify Response Status code

  1. Open Charles Proxy and make sure the proxy is turned on and capturing traffic.
  2. Go to the top menu and click on Tools.
  3. In the dropdown, choose Rewrite.
charles proxy response status
  1. This will open the rewrite settings window Here check Enable rewrite box and click Add.
query param
  1. Rename the rule to your liking and add a location to which the rule should be applied to
  • Protocol: Here you can select your site’s protocol http or https.
  • Host: Here you can enter the host/domain that you want to apply the rule to.
  • Port: You can specify the port on which your site is running.
  • Path: Define the path if you want the rule to apply only to specific paths on the host.
  • Query: Here you can define the query parameters that should be targeted.
charles proxy response status
  1. Now Save the location and click on add in the actions section
charles proxy response status
  • Type: The type tells Charles what to modify. Here we have to select the type of rule we want to use Response Staus.
  • Where : Decide whether to apply the change on the request the response, or both. Since we want to allow CORS we will modify only the response.
  • Match: You need to tell Charles when to apply the rule. This is done by matching specific text in the request URL or we can select Match whole value.
  • Replace: Once a match is found, Charles replaces the text you’ve specified. For example, in this case, we want to replace the status code to 404.

After saving this you should be able to see the rule and its modifications.

Now visit the site you selected and you can check in the network tab that the status codes of requests are changed to 404.

charles proxy response status

Charles Proxy’s Rewrite URL tool can be complicated and time-consuming to set up. You have to go through multiple steps, including navigating the Rewrite Settings, defining conditions, and carefully entering the replacement values to avoid mistakes. Since Charles is a desktop application,  constantly switching between your testing environment and Charles can be frustrating.

With Requestly, this process is much simpler and smoother, saving you time and effort by making it easier to manage everything in one place.

To replicate this in Requestly, you can use the Modify API Response Rule.

Modify API Response rule in Requestly

Say goodbye to the complicated setups of Charles Proxy and simplify your debugging process with Requestly’s Modify Response rule.

Modify API Response Rule lets you intercept and modify API responses based on specific conditions. You can adjust response headers, body content, and status code. This feature is ideal for testing and debugging, allowing you to simulate different responses without altering the actual backend. Rules can be applied based on criteria like URL patterns.

    ” No need to juggle between applications or configure complex rules. “

    Overview of Configuration Options
    1. Options: Here, you can choose between static data or dynamic (JavaScript) data for modifying the response body.
    2. Status Code: This setting allows you to define the status code that should be returned when specific conditions are met.
    3. Source Condition: This condition enables filtering or modifying requests based on their source. In the example, the source is set to a URL containing google.com, meaning only requests containing this URL will be affected.
    4. Filter out Condition: This enables further filtering by defining exceptions or specific rules that exclude certain requests. This makes sure only targeted requests are affected, ignoring the ones that don’t match the conditions.

    Steps to Configure Requestly’s Modify Response rule to modify response status code

    • Install Requestly Extension: Download and install Requestly’s browser extension.
    • Open Requestly Dashboard: Visit app.requestly.io and log in.
    • Click on the Rules tab and then New Rule .
    • Select Modify API Response as the rule type.
    • Specify the URL or URL pattern in the Source Condition.
    • In the Modify API Response section, enter 404 in the Response Status Code field
    • Name your rule and click Save.

    After saving the rule, you can test it. If you’d rather not set it up manually, we’ve created a shared rule for modifying response Body. You can import it by clicking the button below.

    Or create your own Rule by following the guide below

    Interactive Guide

    Check out this interactive and easy explanation of how to create this rule

    Migrate from Charles proxy

    If you already have a Charles Proxy setup and want to give Requestly a try, You can import these tool settings in Requestly in just few clicks

    Requestly currently supports following tools that you can import from Charles Proxy:

    • Rewrite
    • Map Local
    • Map Remote
    • No Caching
    • Block lists
    • Block Cookies

    Steps to import

    1. In Charles Proxy, go to the top menu bar and select Tools > Import/Export Settings.

    Charles proxy menu Import Export settings
    1. In the popup window that appears, switch to the Export tab. Under the Tools section, select the tools you want to export and click the Export button at the bottom right.

    Import Export Setting popup
    1. Open the Requestly dashboard. If you don’t have any existing rules, you’ll see an Import settings from Charles Proxy .

    1. Upload or drag your exported Charles .xml file into Requestly.

    Import charles proxy settings poip up
    1. Once the import is successful, your Charles Proxy settings will be converted into Requestly rules.

    Conclusion

    This article explains how to modify response statuses using Charles Proxy and highlights Requestly as a simpler alternative. While Charles Proxy is effective, Requestly is more user-friendly and integrates directly into your browser, eliminating complex SSL setups and the need to switch between tools. With its 4.4 ⭐ rating from over 1,200 users on the Chrome Web Store, Requestly is a trusted and efficient tool for developers.

    Explore More

    Share this article:

    Subscribe to our weekly newsletter !

    Join 10k developers and QAs to get weekly updates with Requestly's newsletter.​

    This article was written by:

    Picture of Kanishk Rawat

    Kanishk Rawat

    Kanishk Rawat, a tech enthusiast since childhood, has mastered programming through dedication. Whether solo or in a team, he thrives on challenges, crafting innovative solutions .

    Join 10k developers and get weekly updates with Requestly's newsletter.

    Contents