DEV Community

loading...

Modifying API responses with Proxyman (Part I)

renee profile image Renée Updated on ・4 min read

All applications these days seems to communicate over the internet. Most of the time, developers might not need paying much attention to such low level but sometimes, the app doesn't behave as we expect so we might want to use a proxy server like Wireshark, Fiddler, Charles or Proxyman to view all HTTP and HTTPS traffic between the device and the internet.

Alt Text

This blog post explores one of the most useful features of those debugging tools that used daily by both QAs and developers named Map Local. It is powerful in debugging mobile and web applications as it allows developers and testers to change the response of the request, per the configured mappings, so that the response is transparently served from the new location locally as if that was the original request.


Get Started

Normally, testers will need to go through complicated flows in the app in order to have the response properties updated accordingly. The Map Local tool comes in handy to help us to quickly modify the response and change the required parameter to what we need, so that we are able to test different use cases.

Before we enable this feature, we first need to download and launch Proxyman. Then use Cmd + F to search for a specific name and Pin feature to isolate our wanted URL for later modification.

Alt Text

Now we could easily double click the URL to see the content of both Request and Response

Alt Text

At this time, we can choose one among three ways to enable the Map Local tool

  • Right click the URL --> select Tools --> Map Local

Alt Text

  • Click Menu bar --> select Tools --> Map Local

Alt Text

  • Use hotkey Option + Cmd +L

Modify the Response

As soon as the Map Local is enabled, a new window would pop-up to help us monitor upcoming API calls.

Alt Text

Because I have right-clicked an URL to enable Map Local, we can see that Proxyman auto-saves the origin Response of that URL and allows me to open it with my preferred Editor for modification. Thus, we can easily change those parameters for different testing purpose

Alt Text

Create Matching Rules

The next step is to define rules for upcoming Requests. This way, if Proxyman detect any API calls that match our rule, it will replace the content of the Response with our modified one in the local directory.

Although Proxyman has pre-filled domain, we can type in any other domain name for mapping. 

Alt Text

Tips: Check/uncheck the box to allow Proxyman to catch its sub-domains. For example, /v1/posts with checked-box will map all sub-URLs such as /v1/posts?days_ago=0. Meanwhile, /v1/posts with unchecked-box will only map the exact name /v1.posts

Alt Text

After we select the previously modified Response and hit Done, a new rule will be created. As a result, any API calls that satisfy the rule will have the Response served from the local file

Alt Text

Alt Text

Note: we are able to select a different content format for mapping, for example

Alt Text

... and the content might appear as follow

Alt Text

As it might be a system vulnerability so be sure with your intended format of Response when testing in .production environment

What's next?

Modifying responses is very useful when it comes to developing and testing mobile applications. Using the "Map Local" will allow developers or testers to simulate responses from each request then put on the 'hacker hat' and try to debug or break the app. 

In the next blog post, we will discover how to use Proxyman's Map Local tool for mapping a whole directories instead of mapping individual files. It is an easy and convenient way when you need to test complicated response content including css, swf or image. Stay tuned and see you in our next blog post!


Proxyman is a high-performance macOS app, which enables developers to view HTTP/HTTPS requests from apps and domains on iOS device, iOS Simulator and Android devices. Get it at https://proxyman.io

Discussion (0)

pic
Editor guide