I need to copy tasks from one project to another in MS Project 2016 using JSOM or REST API. I used code like this:

function AddTaskToProjectREST(TaskToAdd) {
    url:  "/pwa/_api/ProjectServer/Projects('d70c6d47-e909-45ee-b1b6-0b1c2e5e7ef3')/Draft/Tasks/Add",
    type: "POST",
    headers: {
                    "accept": "application/json;odata=verbose",
                    "content-type": "application/json;odata=verbose",
                    "X-RequestDigest": $('#__REQUESTDIGEST').val(),
                    "X-HTTP-Method": "MERGE",
                    "If-Match": "*"
    body: {
                "Id": TaskToAdd.GUID,
                "Name": TaskToAdd.Title,
                "Notes": TaskToAdd.Comment,
                "Start": new Date().toISOString(),
                "Duration": TaskToAdd.DurationInBillable,
                "AddAfterId": TaskToAdd.PredeceessorGUID
    success: function (data) {
        if (data.d.results) {
            alert("Task added successfully");
    error: function (xhr) {
        alert(xhr.status + ': ' + xhr.statusText);


but it returns a 403 FORBIDDEN error. I have administrator rights in PWA and I can create tasks in MS Project. Can anyone show me a full code that creats a task in a project please?


Finally I found the answer here: https://github.com/OfficeDev/Project-Samples/tree/master/Copy-Work-Packages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.