none
Change Timesheet Hours by REST using POST method RRS feed

  • Question

  • Hi ,

    I am working on Project online and want to update Timesheet hours of a particular task through REST API call.

    Below code not working for me :

        

    function updateProjectCustomFields() {
        _surlWeb = _spPageContextInfo.webServerRelativeUrl;

        if (_surlWeb.length > 0 && _surlWeb.substring(_surlWeb.length - 1, _surlWeb.length) != "/") {
            _surlWeb += "/";
        }
        var requestUri = _surlWeb + "/_api/ProjectServer/TimeSheetPeriods('a976af7d-c90e-e711-80d6-00155d40830b')/TimeSheet/Lines('273a3455-167d-d118-00a7-e9c186324ab9')";
        $.ajax({
            url: requestUri,
            type: 'POST',
            body: JSON.stringify({

                "TaskName": "8"
            }),
            contentType: "application/json;odata=verbose",
            async: false,
            headers: {
                "Authorization": "Basic",
                "ACCEPT": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                "IF-MATCH": "*",           
            },
            success: function (data, request) {
                debugger;
                testdata = data.d;            
                alert("Hours Updated");
            },
            error: function (data, request) {
                debugger;
                testdata = data.d;
            }

        });
    }

    request u to help.


    Amey Pusalkar

    Thursday, March 23, 2017 9:03 AM