使用 REST API 错误在 Project Server 时间表行中创建工作 Object

Create Work Object in Project Server Timesheet Line using REST API Error

所以我尝试构建使用项目服务器 2013 REST API 的移动应用程序。这里的目标是编辑特定时间表中的每一行,包括删除和添加 object。问题是,如果我想在 PWA 中未使用此 POST 方法

设置的任何一天制作 'work' object

https://myweb.com/PWA/_api/ProjectServer/TimeSheetPeriods('mytimesheetId')/TimeSheet/Lines('choosenlineId')/Work/Add

有了这个 body,

{
    "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 本身有关,因为我在 body 中输入的参数已经符合 Add() 方法的要求。有人有想法吗?

提前致谢

我找到了解决方案。 REST API 工作正常,但为了使用 POST 方法调用它,您必须传递所有需要的参数,否则它会给您这些错误。

'parameters': {
        'ActualWork':'value', 
        'Comment':'value', 
        'End':'value', 
        'NonBillableOvertimeWork':'value', 
        'NonBillableWork':'value', 
        'OvertimeWork':'value', 
        'PlannedWork':'value', 
        'Start':'value'     
    }