There are many situations where you may need to modify a request’s response status, such as testing error handling, simulating server downtimes, or verifying how your app responds to specific status codes. Configuring response status modifications in Charles Proxy can be tricky and time-consuming, requiring multiple steps and hard-to-locate options.
Now, imagine achieving the same result with just a few clicks, right within your browser. With Requestly’s Modify Response rule, you can effortlessly change the response status in seconds, without navigating Charles Proxy’s complex interface. Simply install the Requestly Chrome extension and experience an intuitive, streamlined process.
Charles Proxy's Rewrite Tool: How It Works
Configuring the Rewrite tool in Charles Proxy can be a time-consuming process. It requires navigating through a series of options, which can be difficult to find and set up, especially for users unfamiliar with the tool.
How to Configure Charles Proxy’s Rewrite Tool
-
Open Charles Proxy and ensure that your
proxy is enabled
andtraffic
isbeing captured
. -
Navigate to the Tools Menu:
- In the top menu, click on
Tools
. - From the dropdown, select
Rewrite
.
- In the top menu, click on
This will open the rewrite
settings window Here check Enable rewrite
box and click Add
.
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
orhttps
. -
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 thehost
. -
Query: Here you can define the
query parameters
that should be targeted.
Now Save
the location and click on add in the actions section
-
Type: The type tells Charles what to modify. Here we have to select the type of rule we want to use
Response Staus
. -
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 selectMatch 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
.
While Charles Proxy’s Rewrite URL tool is highly versatile, it does require multiple steps to set up and configure properly. Users often need to navigate the Rewrite Settings, define conditions, and carefully input the Replacing value to ensure accuracy. Additionally, as Charles is a desktop application, switching between your testing environment and the proxy can be cumbersome.
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. While Charles Proxy requires multiple steps and a separate desktop app to modify response statuses, Requestly offers a faster, more user-friendly solution directly in your browser. Easily simulate various server responses or test error handling with just a few clicks—no need to juggle between applications or configure complex rules.
- Install Requestly Extension: Download and install Requestly’s browser extension.
- Open Requestly Dashboard: Click on the Requestly icon in your browser toolbar to access the Requestly dashboard.
- Configure Modify Response rule: Here, you can set up conditions to change the status code of any API response.
- Static Data: This option allows you to provide a fixed response body when a certain condition is met. The response will not change dynamically but will always return the static data you define.
- Dynamic: This selection enables you to use a dynamic JavaScript function to generate the response body. Instead of fixed data, you can define conditions or behaviors that alter the response based on the request.
- GraphQL API: Here, you can choose the GraphQL API as your resource type. It indicates that the system will interact with GraphQL-based queries and mutations rather than traditional REST APIs.
-
Response Status Code: This setting allows you to define the status code that should be returned when specific conditions are met. In this case, a
404
status code is chosen, which indicates that the requested resource could not be found. - 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.
- Test URL Condition: This option allows you to test and verify that the defined rules work properly. You can input a URL and see if the conditions, such as status code modifications or request handling, behave as expected.
- 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.
After saving the rule, you can test it on your desired API. If you’d rather not set it up manually, we’ve created a shared rule for modifying response statuses. You can import it by clicking the button below.
Install Requestly Browser Extension if not installed already
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
Guide
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
- In Charles Proxy, go to the top menu bar and select
Tools > Import/Export Settings
.
- In the popup window that appears, switch to the
Export
tab. Under theTools
section, select the tools you want to export and click theExport
button at the bottom right.
- Open the Requestly dashboard. If you don’t have any existing rules, you’ll see an
Import settings from Charles Proxy
. - You can also open it from https://app.requestly.io/import-settings-from-charles
- Upload or drag your exported Charles
.xml
file into Requestly.
- Once the import is successful, your Charles Proxy settings will be converted into Requestly rules.
Conclusion
This article has provided you with a clear understanding of how to modify response statuses in Charles Proxy and how Requestly can accomplish the same task with much greater simplicity. While Charles Proxy is effective, Requestly offers a more seamless and efficient solution.
Since Requestly works directly within your browser and utilizes native browser APIs, there’s no need to deal with complex SSL setups, avoiding the SSL issues commonly faced with Charles Proxy. Plus, you don’t have to switch between multiple tools—everything is right at your fingertips in the browser.
Requestly’s outstanding support and ease of use are backed by its 4.4 ⭐ rating from over 1,200 users on the Chrome Web Store, proving it’s a highly trusted and reliable tool for developers.