Change Project Owner Project Online CSOM WebService RRS feed

  • Question

  • Hi Experts.

    I have a code I am working with and I need to solve this operation, In this code I can't update the owner of the Project in Project Online , I have a WebMethods, and I have a WebApplication to change the owner of the project , could someone help me with the right code to change the Owner of the Project Online CSOM in webservice:

    You can see 3 methods,:


    Just I need help with the webMethod UpdateOwner, because the another 2 methods working fine

    using Microsoft.ProjectServer.Client;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Security;
    using System.Web;
    using System.Web.Services;
    using Microsoft.SharePoint.Client;
    namespace WebApplication2
        /// <summary>
        /// Summary description for WebService1
        /// </summary>
      //  [WebService(Namespace = "NAME OF THE AZURE APP SERVICE")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        // [System.Web.Script.Services.ScriptService]
        public class WebService1 : System.Web.Services.WebService
            private static ProjectContext projContext;
            private const string pwaSite = "NAME OF TENANT PWA SITE";
            private const string psuserName = "SERVICE ACCOUNT FULL USERNAME";
            private const string pspassword = "PASSWORD OF THE SERVICE ACCOUNT";
            public bool myCreateProject()
            public void UpdateECF;
            public void UpdateOwner(string Prj, string ownername)
                using (ProjectContext ProjectCont = new ProjectContext(pwaSite))//PWA Url
                    SecureString _password = new SecureString();
                    foreach (char c in pspassword.ToCharArray()) _password.AppendChar(c);
                    string _loginname = ownername;
                    string _userName = ownername; // Get string from user
                    string _projectname = Prj;
                    ProjectCont.Credentials = new SharePointOnlineCredentials(_userName, _password);
                    //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).Where(p => p.Name == Prj));
                    PublishedProject pubProj = ProjectCont.Projects.First();
                    DraftProject draft = pubProj.Draft;
                    JobState job1 = ProjectCont.WaitForQueue(draft.CheckIn(true), 20);
                    DraftProject projCheckedOut = pubProj.CheckOut();
                    projCheckedOut.Name = Prj;
                    ProjectCont.Load(draft, p => p.Owner);
                    User owner = GetUser(_userName, _loginname, ProjectCont);
                    draft.Owner = owner;
            private User GetUser(string _userName, string _loginname, ProjectContext projectCont)
                throw new NotImplementedException();
        } }

    Please any help will be very useful 

    • Edited by Dan Williamsons Tuesday, January 15, 2019 7:26 PM Mistake in the first entry
    Tuesday, January 15, 2019 3:18 PM


All replies