using Newtonsoft.Json.Linq; //JSON.Net
static void Main(string[] args)
{
var webUri = new Uri("https://Your SharePoint Server/sites/IA/");
const string userName = "username";
const string password = "password";
var securePassword = new SecureString();
foreach (var c in password)
{
securePassword.AppendChar(c);
}
var credentials = new SharePointOnlineCredentials(userName, securePassword);
var list = GetList( credentials);
//print List title
Console.WriteLine(list["Title"]);
}
public static JToken GetList(ICredentials credentials)
{
using (var client = new WebClient())
{
client.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
client.Credentials = credentials;
client.Headers.Add(HttpRequestHeader.ContentType, "application/json;odata=verbose");
client.Headers.Add(HttpRequestHeader.Accept, "application/json;odata=verbose");
var result = client.DownloadString("https://Your Server name/sites/IA/_api/web/lists/getbytitle('Listname')");
var t = JToken.Parse(result);
return t["d"];
}
}