The tutorial shows how to map an API endpoint response with a JSON file. This is good for testing API endpoint response and for faster prototyping.
Android Studio — to run Android emulator
Charles — Map response API to a JSON file
Setup Charles to connect with your Android device
Enable SSL Proxying:
- Charles -> Proxy -> Enable SSL Proxying (now we can see network responses)
Now connect an Android device to the laptop:
1. Go to the Android device’s wifi settings.
2. Select “Modify network” and select “advanced options”.
3. In the menu setting “Proxy” (select manual).
4. In the menu setting “Proxy hostname” enter your laptop’s IP address 192.xx.xx.xx. Get your laptop’s IP from Charles, open Charles, go to Help, Local IP address.
5. In the menu setting “Proxy Port” enter 8888.
6. Charles console now you can see the Android devices network logs.
Add Charles Cert to Android device:
Open Charles, go to Help -> SSL Proxying -> Install Charles Root Certificate on a Mobile Device or Remote Browser
- Setup an Android device with Charles: change wifi settings to use “Manual Proxy”, point to your local IP (steps above).
- On Android device go to chls.pro/ssl and install the cert. Name the downloaded cert and select ‘VPN and apps”.
Change SSL Proxy Settings:
- Open Charles, go to Proxy -> SSL Proxying Settings -> click “Add”
Change API response endpoint with the JSON file.
- Get the API’s endpoint URL.
- Open Charles. (read above to setup Charles).
- Charles -> Tools -> Map Local.
- Fill Host (API endpoint URL) click enter (it will autofill the path and query).
- Now choose the path to the downloaded JSON, click ok.
It will reroute home API endpoint response to the content of the JSON file :)
Thanks for reading and let me know if I’m wrong somewhere or if there’s something that could do differently or better. I’m open to your feedback 🙌🏻
The Map Remote tool changes the request location, per the configured mappings, so that the response is transparently…
Setting up Charles to Proxy your Android Device
This article describes the steps required to set up your Android device to proxy network requests through Charles…