Hi @Bommisetty, Gayatri, I will recommend you to use CSOM to access SharePoint Online. You can refer to following code
using (var clientContext = new ClientContext("https://company.sharepoint.com/sites/xxx")){
// SharePoint Online Credentials
var pwd = "************";
var passWord = new SecureString();
foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c);
clientContext.Credentials = new SharePointOnlineCredentials("******@wxx.onmicrosoft.com", passWord);
// Get the SharePoint web
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();
List targetList = clientContext.Web.Lists.GetByTitle("List Name");
CamlQuery oQuery = CamlQuery.CreateAllItemsQuery();
ListItemCollection oCollection = targetList.GetItems(oQuery);
clientContext.Load(oCollection);
clientContext.ExecuteQuery();
foreach (ListItem oItem in oCollection)
{
Console.WriteLine(oItem["Title"].ToString());
}
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.