Aju Aju - 5 months ago 33
Android Question

Api calls in the app is not able to be debugged in Charles/Fiddler (Bypassing proxy)

My App is developed using Xamarin.Android. When I try to do API debugging using Charles, I am not able to see the APIs in Charles. But I can see APIs of the other Apps installed in my device.

I have set the proxy in the android device taking IP from my system.

Here is the code which I have used in the PCL code, which is used for both IOS and Android.

return new HttpClient(new AuthenticatedHttpClientHandler(new NativeMessageHandler()))
BaseAddress = new Uri(baseUrl),
Timeout = new TimeSpan(0, 0, timeout)

public class AuthenticatedHttpClientHandler : DelegatingHandler
public AuthenticatedHttpClientHandler(HttpMessageHandler innerHandler) : base(innerHandler)
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

This is common code written in PCL.
In IOS APIs are not getting bypassed from the proxy and able to track it in Charles.


The Mono HttpClient isn't using the proxy settings. Configure your app to use the native ClientHandler.


  • add a file to your project
  • insert XA_HTTP_CLIENT_HANDLER_TYPE=Xamarin.Android.Net.AndroidClientHandler
  • set Build Action to AndroidEnvironment

enter image description here

or create your HttpClient like:

var client = new HttpClient (new Xamarin.Android.Net.AndroidClientHandler ());