none
When calling QueueAddToProject() in PSI, it returns ProjectCannotAdd error RRS feed

  • Question

  • Dear Experts,

    I am working on a PSI server and am new to it. I am trying to add tasks to an existing project using the QueueAddToProject() as defined in SDK. I am not sure what am I missing but when trying to call the QueueAddToProject(), it returns an PSClientError as "ProjectCannotAdd"

     

    Please help!

    • Changed type Hans.HModerator Tuesday, August 9, 2011 8:24 PM TS wants to mark post as answer
    Monday, August 8, 2011 7:26 PM

Answers

  • Hi Hans,

    I got the issue. I was sending a null ProjectDataSet in my code while calling QueueAddToProject(). Issue fixed now. IN above code, where I am sending projDs, it should be ds and not projDS.

    Thanks for your time!


    Nitesh.
    Tuesday, August 9, 2011 7:04 PM

All replies

  • Hi,

    Did you check-out the project in code before trying to add tasks?
    Are you setting the TASK_WBS property? You should not set this.
    Does the user with which you run the code have the correct permissions on the project?
    Are you trying to set porperties in conflict with the project settings?

    As a test, login to Project Server with the user under which the code runs and try to add the tasks manually and save the project. If this succeeds, its not a permission problem and there must be something wrong in your code.

    Compare your code with the sample code in the SDK and see if there are any differences. Temporary comment out as much code as possible to get as close as possible to the sample code. This way you might find out what is causing the error.

    I hope this helps,
    Hans


    My EPM blog: Projectopolis
    Monday, August 8, 2011 8:02 PM
    Moderator
  • Hi Hans,

    I am not settign the TASK_WBS property.

     

    I created a project from Code manually. Then after the project gets created, checkout the project using the projectID, create a new object of projectdataset to insert data, add tasks to DS and call the QueueAddToProject() method.

     

    Do you think this has something to do with Code. I am using the project.DefaultCredentials=CredentialCache.NetworkCrdential as credentials and I am logged in as an administrator to the dev machine.

     

    Thanks again for your help!


    Nitesh.
    Monday, August 8, 2011 8:20 PM
  • Hi Nitesh,

    It could be a security related problem, hence my suggestion to try the action manually (make sure to use the user that performs the update from PSI).

    In addition, try to get as much info about the error as possible (event log, ULS log, ...) although my guess is that not much info will be logged.

    You could also post a code snipplet that you use to check-out and update the project and I'll have a quick look at it.

    Regards,
    Hans


    My EPM blog: Projectopolis
    Monday, August 8, 2011 8:31 PM
    Moderator
  • Hi Hans,

    I am bit worried about the error. It throws "ProjectCannotAdd" error. I went through the MSDN and found that this means "we cannot use the QueueAddToProject() on server-side project". Not sure, how to deal with this. I will try to view the logs and see what I can get out of it.

    Regarding code snippet, it goes as below:

                   

    projectID = GetProjectIDFromName("testproject");//This project has been created already by code
            if (projectID != Guid.Empty)
            {
              Console.WriteLine("ProjectID found");
              //Read Project from ProjectID
              //projDS = proj.ReadProject(projectID, DataStoreEnum.WorkingStore);
              //Console.WriteLine("Project read from PWA");
    
              //Checkout the project to add tasks
              proj.CheckOutProject(projectID, sessionID, "Checking out Project for adding Tasks");
              Console.WriteLine("Project checkedout");
    
              //Create a new DS to insert new data
              ProjectDataSet ds = new ProjectDataSet();
              //Adds 4 tasks
              CreateTask(ds, "Task One", projectID, 1, 1);
              CreateTask(ds, "Task Two", projectID, 1, 2);
              CreateTask(ds, "Task Three", projectID, 2, 3);
              CreateTask(ds, "Task Four", projectID, 2, 5);
              Console.WriteLine("4 tasks added");
              Console.WriteLine("Update Started");
              jobID = Guid.NewGuid();
              proj.QueueAddToProject(jobID, sessionID, projDS, false);
              WaitForQueue(jobID);
            }
            else
            {
              Console.WriteLine("Project Name not found!");
            }
          }
          catch (SoapException ex)
          {
            PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
            PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
            Console.Write(ex.ToString());
            for (int i = 0; i < errors.Length; i++)
            {
              Console.WriteLine(errors[i].ErrId);
              for (int j = 0; j < errors[i].ErrorAttributes.Length; j++)
              {
                Console.WriteLine(errors[i].ErrorAttributeNames()[j] + ":" + errors[i].ErrorAttributes[j]);
              }
            }
          }
          catch (Exception ex)
          {
            Console.WriteLine(ex.ToString());
          }
          finally
          {
            if (projectID != Guid.Empty)
            {
              Console.WriteLine("Checkin started");
              jobID = Guid.NewGuid();
              proj.QueueCheckInProject(jobID, projectID, true, sessionID, "Checkign In after adding tasks");
              WaitForQueue(jobID);
            }
          }
    



    Nitesh.
    Tuesday, August 9, 2011 6:40 PM
  • Hi Hans,

    I got the issue. I was sending a null ProjectDataSet in my code while calling QueueAddToProject(). Issue fixed now. IN above code, where I am sending projDs, it should be ds and not projDS.

    Thanks for your time!


    Nitesh.
    Tuesday, August 9, 2011 7:04 PM
  • Good you found it.

    I was just typing a response pointing you to this issue...

    Glad to help!

     


    My EPM blog: Projectopolis
    Tuesday, August 9, 2011 7:09 PM
    Moderator
  • Can't I mark my post as Answer?

    This would help someone else if struggling with this issue!


    Nitesh.
    Tuesday, August 9, 2011 8:23 PM
  • I have changed the thread type to 'Question' and marked your post as answer.


    My EPM blog: Projectopolis
    Tuesday, August 9, 2011 8:25 PM
    Moderator
  • Thanks!
    Nitesh.
    Wednesday, August 10, 2011 11:38 AM