因此,我尝试构建使用project server 2013 REST API的移动应用程序。这里的目标是编辑特定时间表中的每一行,包括删除和添加对象。问题是,如果我想在任何一天使用这个POST方法创建一个没有在PWA中设置的'work‘对象,
https://myweb.com/PWA/_api/ProjectServer/TimeSheetPeriods('mytimesheetId')/TimeSheet/Lines('choosenlineId')/Work/Add
有了这个身体,
{
"parameters": {
"End":"2020-02-10T23:59:59",
"Start":"2020-02-11T00:00:00",
"ActualWork": "8h",
"Comment": null,
"NonBillableWork": "0h",
"OvertimeWork": "0h",
"PlannedWork": "0h"
}
}我将收到此错误消息,
{
"error": {
"code": "42, Microsoft.ProjectServer.PJClientCallableException",
"message": {
"lang": "en-US",
"value": "PJClientCallableException: GeneralUnhandledException\r\nGeneralUnhandledException\r\nException = System.InvalidCastException: Cannot cast DBNull.Value to type 'System.Decimal'. Please use a nullable type.\r\n at System.Data.DataRowExtensions.UnboxT`1.ValueField(Object value)\r\n at Microsoft.Office.Project.Server.BusinessLayer.Timesheet.<ApplyChanges>b__c0(ActualsRow actualsRow)\r\n at Microsoft.Office.Project.Server.Library.PSUtility.Apply[T](IEnumerable`1 enumerable, Action`1 fn)\r\n at Microsoft.Office.Project.Server.BusinessLayer.Timesheet.ApplyChanges(TimesheetDataSet changes)\r\n at Microsoft.Office.Project.Server.BusinessLayer.TimeSheet.UpdateTimesheet(Guid tsUID, TimesheetDataSet timesheetDS)\r\n at Microsoft.Office.Project.Server.BusinessLayer.TimeSheet.QueueUpdateTimesheet(Guid jobUID, Guid tsUID, TimesheetDataSet dsDelta)\r\n at Microsoft.Office.Project.Server.Wcf.Implementation.TimeSheetImpl.<>c__DisplayClass31.<QueueUpdateTimesheet>b__30()\r\n at Microsoft.Office.Project.Server.Wcf.Implementation.WcfMethodInvocation.InvokeBusinessObjectMethod(String businessObjectName, String methodName, IEnumerable`1 actions)"
}
}
}我认为这与Project Server 2013本身有关,因为我在正文中输入的参数已经是Add()方法所请求的。有谁有主意吗?
提前谢谢你
发布于 2020-02-27 14:40:19
我找到了解决方案。REST API工作得很好,但是为了使用POST方法调用它,你必须传递所有需要的参数,否则它会给你这些错误。
'parameters': {
'ActualWork':'value',
'Comment':'value',
'End':'value',
'NonBillableOvertimeWork':'value',
'NonBillableWork':'value',
'OvertimeWork':'value',
'PlannedWork':'value',
'Start':'value'
}https://stackoverflow.com/questions/60200979
复制相似问题