DefaultRequestHeaders is null in xamarin.forms for iOS and android

I am using the following code and DefaultRequestHeaders is coming as null incase of iOS and android where as working properly in windows device.

NetworkCredential proxyCreds = new NetworkCredential(username, password, doamin);
HttpClientHandler handler = new HttpClientHandler();
handler.Credentials = proxyCreds;
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(handler);
client.BaseAddress = new System.Uri("http://sharepointURL:80/qwe/asd/");
string cmd = "_api/contextinfo";
client.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");
client.DefaultRequestHeaders.Add("ContentType", "application/json");
client.DefaultRequestHeaders.Add("ContentLength", "0");
StringContent httpContent = new StringContent(string.Empty);

Sign In or Register to comment.