DEV Community

Requestly
Requestly

Posted on • Originally published at requestly.com on

How to Inspect & Modify HTTP Traffic from Android Apps

In order to quickly ship an Android app that your users love, you need to make sure it’s tested thoroughly. Today there are a number of tools that you can use to expedite the process of testing, building, and shipping your apps quickly. One such tool is Requestly. It’s an open-source platform, and you can use it to inspect and modify traffic from your Android apps easily.

In this blog post, I’ll walk you through how you can use Requestly to inspect network traffic, simulate API failures and redirect API calls on Android apps.

Setup

  1. First, head over to Requestly and download and install their desktop app on your system.
  2. Once installed, open the Requestly desktop app and click on Connect apps
  3. Then, choose the *Mobile Apps and Browsers * section:
  4. Then, choose the Android External Device option and click on Setup Instructions
  5. You will get a list of setup instructions that will tell you how to install a proxy on your Android device to enable Requestly to intercept traffic from your Android device.

Install Proxy and Add Certificate on your Android Device

To enable Requestly to intercept and modify network traffic from your Android apps, you need to install a proxy on your device and add the associated certificate. Follow these steps:

  1. Install a proxy app like ProxyDroid or Packet Capture from the Google Play Store on your Android device.
  2. Configure the proxy app as a system proxy on your device according to the instructions provided by the app.
  3. Download the Requestly certificate from the Requestly desktop app or website.
  4. Install the Requestly certificate on your Android device by following the instructions provided by the proxy app.

Inspecting Traffic

Now that you have set up Requestly and installed the proxy on your Android device let’s explore how to inspect HTTP traffic from Android apps:

  1. Launch the app you wish to inspect, such as an internationally popular app like Amazon or Twitter.
  2. Open the proxy app on your Android device and start capturing network traffic.
  3. Use the app as you normally would. The proxy app will intercept and display the network requests and responses made by the app.
  4. Analyze the network requests to gain insights into the app’s behavior.
  5. You can examine request headers, URL parameters, response headers, and more.

Modifying API Responses

Requestly allows you to modify API responses on the fly, enabling you to simulate different scenarios and test your app’s behavior. Here’s how to modify an API response:

  1. In the proxy app on your Android device, locate the network request for the API you want to modify. For example, let’s consider the API request for creating a new tweet on Twitter.
  2. Long-press on the network request in the proxy app’s network table to reveal a context menu.
  3. From the context menu, select the option to modify the response. A text editor will open, allowing you to modify the response body, headers, or status code.
  4. Make the desired changes to the API response. You can tweak the response data, add custom headers, or simulate error conditions.

Simulating API Failures

With Requestly, you can simulate API failures by setting the HTTP status code to indicate an error. This helps you verify how your app handles unexpected responses. Follow these steps:

  1. Locate the network request for the API you want to make fail in the proxy app.
  2. Long-press on the network request and select the option to modify the response.
  3. Change the HTTP status code to a relevant error code, such as 500 (Internal Server Error).
  4. Save the modifications, and the API request will now appear to fail, allowing you to observe how your app handles such scenarios.

Redirecting API Calls

Requestly also allows you to redirect API calls to a local development server, facilitating testing against a specific environment. Here’s how to redirect an API call:

  1. Identify the network request you wish to redirect in the proxy app.
  2. Long-press on the network request and choose the option to modify the response.
  3. Change the request URL to the desired local development server URL.
  4. Save the modifications, and the API request will now be redirected to your local development server, enabling you to test against your local environment.

SSL-Pinning

It’s important to note that the Requestly desktop app does not offer SSL pinning capabilities. If the app you’re testing utilizes SSL pinning, Requestly may not be able to intercept and modify its traffic. In such cases, additional measures or alternative tools may be required for testing.

Conclusion

By incorporating Requestly into your Android app development toolkit, you can inspect and modify HTTP traffic with ease. Requestly enables you to gain valuable insights into app behavior, simulate various scenarios, and test your app’s resilience to different network conditions. With its user-friendly interface and powerful features, Requestly helps you streamline your development workflow and deliver high-quality Android apps. So, give Requestly a try and experience the convenience and efficiency it brings to your Android app development process!

Remember, by leveraging Requestly, you’ll be equipped with a powerful toolset to tackle the challenges of app development, ensuring your apps are robust and reliable.

Happy debugging!

Originally published at https://requestly.comf.


Top comments (0)