Create Project in Project Online using CSOM

Create Project in Project Online using CSOM:-

Create Project in Project Online using CSOM. In this post, I will explain you Programmatically Create Project in Project Online using CSOM. Before to create the project in project online using CSOM, you must use the Microsoft.ProjectServer.Client namespace instead of the PSI. How to add namespaces and dll reference in csom, I already told you in my previous post. I also explain to you how to create project using psi

YouTube Link, Please like and subscribe my channel

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.ServiceModel;
using System.Data;
using Microsoft.ProjectServer.Client;
using Microsoft.SharePoint.Client;
using System.Security;

namespace Create_Project
    class Program
        static string UserName = "User Name";
        static string Passwords = "Password";
        public static string OnlinePWA = "PWA Path";
        static void Main(string[] args)
        private static void CreatePoject()
            using (ProjectContext ProjectCont = new ProjectContext(OnlinePWA))//PWA Url
                SecureString passWord2 = new SecureString();
                foreach (char c in Passwords.ToCharArray()) passWord2.AppendChar(c);
                ProjectCont.Credentials = new SharePointOnlineCredentials(UserName, passWord2);
                c => c.IncludeWithDefaultProperties(pr => pr.StartDate, pr => pr.CustomFields, pr => pr.Assignments, pr => pr.FinishDate, pr => pr.Owner.LoginName, pr => pr.Tasks, pr => pr.ProjectSiteUrl, pr => pr.PercentComplete, pr => pr.ProjectResources, pr => pr.CustomFields, pr => pr.EnterpriseProjectType));
                ProjectCreationInformation newProj = new ProjectCreationInformation();
                newProj.Id = Guid.NewGuid();
                newProj.Name = "Test Project with CSOM";
                newProj.Description = "Test creating a project with CSOM";
                newProj.Start = DateTime.Today.Date;
                PublishedProject newPublishedProj = ProjectCont.Projects.Add(newProj);               
                JobState jobState = ProjectCont.WaitForQueue(ProjectCont.Projects.Update(), 300);



  1. Thanks for your code, The same way I need to read all employee timesheets of Project Online using CSOM?.

    Please suggest me the best approach, where I can read all timesheets from Project Online based on resource type and need to export to csv ?

  2. We have a required custom field. Trying:
    pci = new ProjectCreationInformation();
    pci.Id = Guid.NewGuid();
    pci.EnterpriseProjectTypeId = _eptid;
    pci.Name = projectname;
    pci.Description = xxx; //non-relevant function for this question
    pci.Start = DateTime.Now;

    PublishedProject pub = _prj.ProjectContext.Projects.Add(pci);
    pub.Owner = xxx; //(non-relevant code here)
    //adding our custom field here
    pub.SetCustomFieldValue(internalname,parray); //parray because it’s a lookup table
    QueueJob qj = _prj.ProjectContext.Projects.Update();
    JobState jb = _prj.ProjectContext.WaitForQueue(qj, 300);
    The jb line always fails with “Value cannot be null.
    Parameter name: row”

    what are we doing wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!