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

%3CLINGO-SUB%20id%3D%22lingo-sub-1171040%22%20slang%3D%22en-US%22%3ECreate%20Work%20Object%20in%20Project%20Server%20Timesheet%20Line%20using%20REST%20API%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1171040%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20so%20i%20try%20build%20mobile%20app%20that%20consumes%20project%20server%202013%20REST%20API.%20The%20goal%20here%20is%20to%20edit%20each%20individual%20line%20in%20a%20certain%20timesheet%2C%20including%20delete%20and%20add%20object.%20The%20problem%20is%20if%20i%20want%20to%20make%20a%20'work'%20object%20at%20anyday%20that%20hasn't%20been%20set%20in%20PWA%20using%20this%20POST%20Method%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22%3CA%20href%3D%22https%3A%2F%2Fmyweb.com%2FPWA%2F_api%2FProjectServer%2FTimeSheetPeriods('mytimesheetId')%2FTimeSheet%2FLines('choosenlineId')%2FWork%2FAdd%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmyweb.com%2FPWA%2F_api%2FProjectServer%2FTimeSheetPeriods('mytimesheetId')%2FTimeSheet%2FLines('choosenlineId')%2FWork%2FAdd%3C%2FA%3E%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ewith%20this%20body%2C%3C%2FP%3E%3CP%3E%7B%20%22parameters%22%3A%20%7B%20%22End%22%3A%222020-02-10T23%3A59%3A59%22%2C%20%22Start%22%3A%222020-02-11T00%3A00%3A00%22%2C%20%22ActualWork%22%3A%20%228h%22%2C%20%22Comment%22%3A%20null%2C%20%22NonBillableWork%22%3A%20%220h%22%2C%20%22OvertimeWork%22%3A%20%220h%22%2C%20%22PlannedWork%22%3A%20%220h%22%20%7D%20%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20get%20this%20error%20message%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%7B%20%22error%22%3A%20%7B%20%22code%22%3A%20%2242%2C%20Microsoft.ProjectServer.PJClientCallableException%22%2C%20%22message%22%3A%20%7B%20%22lang%22%3A%20%22en-US%22%2C%20%22value%22%3A%20%22PJClientCallableException%3A%20GeneralUnhandledException%5Cr%5CnGeneralUnhandledException%5Cr%5CnException%20%3D%20System.InvalidCastException%3A%20Cannot%20cast%20DBNull.Value%20to%20type%20'System.Decimal'.%20Please%20use%20a%20nullable%20type.%5Cr%5Cn%20at%20System.Data.DataRowExtensions.UnboxT%601.ValueField(Object%20value)%5Cr%5Cn%20at%20Microsoft.Office.Project.Server.BusinessLayer.Timesheet.b__c0(ActualsRow%20actualsRow)%5Cr%5Cn%20at%20Microsoft.Office.Project.Server.Library.PSUtility.Apply%5BT%5D(IEnumerable%601%20enumerable%2C%20Action%601%20fn)%5Cr%5Cn%20at%20Microsoft.Office.Project.Server.BusinessLayer.Timesheet.ApplyChanges(TimesheetDataSet%20changes)%5Cr%5Cn%20at%20Microsoft.Office.Project.Server.BusinessLayer.TimeSheet.UpdateTimesheet(Guid%20tsUID%2C%20TimesheetDataSet%20timesheetDS)%5Cr%5Cn%20at%20Microsoft.Office.Project.Server.BusinessLayer.TimeSheet.QueueUpdateTimesheet(Guid%20jobUID%2C%20Guid%20tsUID%2C%20TimesheetDataSet%20dsDelta)%5Cr%5Cn%20at%20Microsoft.Office.Project.Server.Wcf.Implementation.TimeSheetImpl.%26lt%3B%26gt%3Bc__DisplayClass31.b__30()%5Cr%5Cn%20at%20Microsoft.Office.Project.Server.Wcf.Implementation.WcfMethodInvocation.InvokeBusinessObjectMethod(String%20businessObjectName%2C%20String%20methodName%2C%20IEnumerable%601%20actions)%22%20%7D%20%7D%20%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20think%20this%20has%20something%20to%20do%20with%20the%20Project%20Server%202013%20itself%20since%20the%20parameter%20i%20input%20in%20the%20body%20is%20already%20as%20requested%20by%20Add()%20method.%20Anyone%20has%20idea%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThankyou%20in%20advance%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Visitor

Hi so i try build mobile app that consumes project server 2013 REST API. The goal here is to edit each individual line in a certain timesheet, including delete and add object. The problem is if i want to make a 'work' object at anyday that hasn't been set in PWA using this POST Method,

 

"https://myweb.com/PWA/_api/ProjectServer/TimeSheetPeriods('mytimesheetId')/TimeSheet/Lines('choosenl..."

 

with this body,

{ "parameters": { "End":"2020-02-10T23:59:59", "Start":"2020-02-11T00:00:00", "ActualWork": "8h", "Comment": null, "NonBillableWork": "0h", "OvertimeWork": "0h", "PlannedWork": "0h" } }

 

I will get this error message,

 

{ "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.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.b__30()\r\n at Microsoft.Office.Project.Server.Wcf.Implementation.WcfMethodInvocation.InvokeBusinessObjectMethod(String businessObjectName, String methodName, IEnumerable`1 actions)" } } }

 

I think this has something to do with the Project Server 2013 itself since the parameter i input in the body is already as requested by Add() method. Anyone has idea?

 

Thankyou in advance

0 Replies