Timesheet Entry into Project Server Using Rest API

1.8k Views Asked by At

I'm trying to add timesheet entries against some specific task which is available in the MS Project Server 2013. I have ways of creating TASK in Project Server using REST endpoints, but could not find a way straight forward for the timesheet. I have gathered few details out of some scrutiny at my end:

To See the Complete Meta Data: 
http://>/PWA/_api/ProjectData/$metadata - You can get the field details, Where as I need to know in specific the Entity for TimeSheet.

To See the Complete Time Sheet Period Available:
http://>/PWA/_api/ProjectServer/TimeSheetPeriods - You can see all the available TimeSheet Periods.

I know TimeSheet stays as separate entity and doesn't belong to usual Project Entities.

My Query here to know in specific the Entity that is dealt for timesheet add & update. Please help me with endpoints including the save, publish and checkout!

3

There are 3 best solutions below

0
Bruno Ferreira On

How are you adding the tasks? Http requests? Did you develop some app?

I tried a few ways to add actuals to timesheets already created using REST endpoints, via Postman, without success. It always responds with this error: "The security validation for this page is invalid.", I think I'm missing some headers.

This endpoints were as close as i got:

Submit Timesheet
POST - http://>/pwa/_api/ProjectServer/TimeSheetPeriods('periodid')/TimeSheet/submit(comment)

Update Timesheet
POST - http://>/pwa/_api/ProjectServer/TimeSheetPeriods('periodid')/TimeSheet/update()

I saw this endpoints here.

Hope this helps!

0
O A On

Incase anyone is still struggling with this as I was.... here's what worked for me. To replace the actual work for a given day in a task - to enter your time:

Uri:

http://<sitecollection>/<site>/_api/ProjectServer/TimeSheetPeriods('periodid')/TimeSheet/Lines('lineid')/Work('yyyy-MM-dd') 

Method: PATCH

Headers:

 Accept - application/json;odata=verbose

 Content-type - application/json;odata=verbose

 Odata-version - 3.0

 If-Match: *

Body:

{
"__metadata": {
"type": "PS.TimeSheetWork"
},
"ActualWork": "10"
}

I entered in my times as 10 hrs.

0
Emanuele On

In case you don't have a TimeSheet because the call returns a null object, you have to create it. Just POST a /TimeSheetPeriods('periodid')/createTimeSheet()

https://github.com/akordowski/Project-Server-Resources/blob/master/Project%20Server%20REST%20API%20Endpoints.md#timesheetperiods

https://learn.microsoft.com/en-us/previous-versions/office/project-javascript-api/jj669182(v=office.15)