Has anyone here tried to connect to SharePoint from a Portable class library? I keep getting a 401 response even though my credentials are correct.
I have got it resolved now.
@ekhor , could you plz share the approach.
I used the code snippet below (with the correct credentials) and I am now able to access SharePoint from my Android device via the portable class library.
var handler = new HttpClientHandler();
handler.Credentials = new System.Net.NetworkCredential(username, password, domain);
var client = new HttpClient(handler);
client.BaseAddress = new Uri($"http://contoso.com/");
client.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");//we want to receive JSON rather than XML
var response = await client.GetAsync("_api/web/lists");
var responseText = await response.Content.ReadAsStringAsync();
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies