Backend Development 3 min read

Using Charles Proxy to Modify API Response Values with Map Remote, Map Local, and Rewrite

This article explains how to use Charles Proxy's Map Remote, Map Local, and Rewrite features to alter server responses for client testing, mock data, pagination, and special data handling, providing step-by-step instructions with screenshots for redirecting requests to other URLs, local files, or applying regex replacements.

Test Development Learning Exchange
Test Development Learning Exchange
Test Development Learning Exchange
Using Charles Proxy to Modify API Response Values with Map Remote, Map Local, and Rewrite

Recently I studied how to use Charles to modify response values, which is useful when the client is finished but the server API is not, as well as for special data handling, pagination testing, and similar scenarios.

Charles provides three functions—Map Remote, Map Local, and Rewrite—that can all modify the content returned by a server. Their differences are:

Map Remote redirects a specified network request to another URL.

Map Local redirects a specified network request to a local file.

Rewrite performs regular‑expression replacements on the network response.

1. Map Remote

Right‑click the target request, choose “Map Remote…”, and in the Map Remote Settings page set the URL to which the request should be redirected. After saving, re‑request the interface; the response will now be the redirected data while other interfaces remain in the test environment.

2. Map Local

Right‑click the request and select “Save Response” to store the returned data locally. Then right‑click the same request again, choose “Map Local…”, and in the Map Local Settings page upload the modified local file. After applying the setting, the interface will return the locally edited data.

3. Rewrite

Open Tools → Rewrite, enable the feature, click “Add”, and create a rule. Check the “Response” box, specify the value to replace, and define the regular‑expression pattern. After saving, refresh the client and the latest content will be displayed.

In summary, Charles Proxy allows developers to quickly mock or modify API responses without changing server code, facilitating client‑side testing and debugging.

testingBackend DevelopmentAPI mockingCharles ProxyResponse Modification
Test Development Learning Exchange
Written by

Test Development Learning Exchange

Test Development Learning Exchange

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.