For testing purposes in SharePoint Online (and even SharePoint on-prem) I often use a simple command line tool. Following a simple template as a good starting point.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security;
using Microsoft.SharePoint.Client;

namespace AnyDummy
{
    class Program
    {
        static void Main(string[] args)
        {
            var url = "{add your url here}";
            var user = "{add the username here}";
            var pw = "{add the user password here}";

            var password = new SecureString();
            foreach (char c in pw.ToCharArray()) password.AppendChar(c);

            using (var ctx = new ClientContext(url))
            {
                ctx.Credentials = new SharePointOnlineCredentials(user, password);
				// comment the previous line and use the following line, when running on-premise
				// ctx.Credentials = new System.Net.NetworkCredential(user, password);
				
                Web web = ctx.Web;
                ctx.Load(web);
                ctx.ExecuteQueryRetry();
            }
        }
    }
}

 

Advertisements