Hi @Daniel Turan ,
You can use the SharePoint client object model (CSOM) to retrieve, update, and manage data in SharePoint.
Step 1: Download the latest SharePoint Client Components SDK from Microsoft and install on your local computer.
Step 2: Add references of the portable dlls in your new project, location should be like this C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI.
Step 3: Refer to following code.
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using Microsoft.SharePoint.Client;
namespace ContosoConsole
{
class Repository
{
public void GetApprovedAppsByView(string siteUrl, NetworkCredential credentials, string listName, string viewName, string camlQuery)
{
try
{
using (var context = new ClientContext(siteUrl))
{
context.Credentials = credentials;
List list = context.Web.Lists.GetByTitle(listName);
View view = list.Views.GetByTitle(viewName);
context.Load(view);
CamlQuery query = new CamlQuery();
if (context.HasPendingRequest)
{
context.ExecuteQueryAsync()
.Wait();
}
query.ViewXml = string.Format("<View><Query>{0}{1}</Query></View>", view.ViewQuery, camlQuery);
ListItemCollection items = list.GetItems(query);
context.Load(items);
if (context.HasPendingRequest)
{
context.ExecuteQueryAsync()
.Wait();
}
foreach (ListItem listItem in items)
{
Console.WriteLine(listItem["Title"]);
}
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("Error Message: " + ex.Message);
Console.ReadKey();
}
}
}
}
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.