0

I've tried sending a request to "/_api/ProjectServer/Projects('projectid')/Assignments", but all it does is return duplicates of the last assignment which is weird because the number of objects it returns is always equal to the number of assignments there are in the project.

Basically if I assign a resource to each of a hundred different tasks, the call returns 100 duplicates of the last task's assignment in the list.

I suspect it might be a bug, I'd appreciate it if someone could confirm or deny my assumption and/or let me know if there's any other way to retrieve the list of assignments in a project.

Shengbo1618
  • 1,443
  • 2
  • 9
  • 5

1 Answers1

0

I didn't exactly know how to work with rest but I would like to provide you with litle lines of code using CSOM that, if I understood properly the question, it might help you:

private static void ListPublishedProjects()
        {
            // Get the list of projects on the server.
            projContext.Load(projContext.Projects);
            projContext.ExecuteQuery();

            var proj = projContext.Projects.First(p => p.Name == "<project name>");
            projContext.ExecuteQuery();

            //You must ckeck out the project and load it's tasks
            var draftProj = proj.CheckOut();

            projContext.Load(draftProj.Tasks);
            projContext.ExecuteQuery();  

            //Loop between all tasks
            foreach (DraftTask task in draftProj.Tasks)
            {
                // Load all assignments in that task
                projContext.Load(task.Assignments);
                projContext.ExecuteQuery();

                //Loop between al assignments
                foreach (var assignment in task.Assignments)
                {
                    projContext.Load(assignment.Owner, temp => temp.LoginName, temp => temp.Email);
                    projContext.Load(assignment.Resource);
                    projContext.ExecuteQuery();

                    Console.WriteLine("\n\t RESOURCE NAME:" + assignment.Resource.Name + " => " + assignment.ActualWork);
                }    
            }

            //Remember to publish and checkin the project when you finish your TODOs
            draftProj.Publish(true);
            draftProj.CheckIn(true);
            QueueJob qJob = projContext.Projects.Update();
            JobState jobState = projContext.WaitForQueue(qJob, 200);
        }
 }

Hope it helps,

Marc Lluis
  • 61
  • 7