Forum Discussion

Pavel161's avatar
Pavel161
Copper Contributor
Nov 07, 2024

MS Project Online (CSOM) read Assignment history

I need to get status of approvals of the assignments in MS Project Online I want to look at History, find latest record and see its approval status.

I use following code to retrieve History:

 TimePhase timePhase1 = employee._mspStatusAssignments.GetTimePhase(Start.Date, End.Date);
 _projectContext.Load(timePhase1);
 _projectContext.Load(timePhase1.Assignments);
 _projectContext.ExecuteQuery();

 StatusAssignment statusAssignment1 = timePhase1.Assignments.FirstOrDefault(x => x.Id.ToString() == ID);
 _projectContext.Load(statusAssignment1.History);
 _projectContext.ExecuteQuery();

But this code throws exception at ExecuteQuery when attempt to retrieve History when history has more than 0 items:

Exception Message: The type of data at position 642 is different than the one expected. 
StackTrace:    at Microsoft.SharePoint.Client.JsonReader.ReadDateTime()
at Microsoft.ProjectServer.Client.StatusAssignmentHistoryLine.InitOnePropertyFromJson(String peekedName, JsonReader reader)
at Microsoft.SharePoint.Client.ClientObject.FromJson(JsonReader reader)
at Microsoft.SharePoint.Client.JsonReader.ReadJsonObject(Type fallbackType)
at Microsoft.SharePoint.Client.JsonReader.ReadObject(Type fallbackType)
at Microsoft.SharePoint.Client.JsonReader.ReadObjectArray(Type fallbackElementType)
at Microsoft.SharePoint.Client.ClientObjectCollection`1.ReadChildItems(JsonReader reader)
at Microsoft.SharePoint.Client.ClientObjectCollection.InitOnePropertyFromJson(String peekedName, JsonReader reader)
at Microsoft.SharePoint.Client.ClientObject.FromJson(JsonReader reader)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()

Can anyone suggest what could be causing this problem?

Thank you

No RepliesBe the first to reply

Share

Resources