none
How do you delete tasks in Project Server via REST? RRS feed

  • Question

  • I'm trying to delete some tasks from Project Server using the REST API from an SPFx webpart using the SPFx HttpClient. Here are the steps I'm taking:

    Get the project by sending GET to

    https://server/site/_api/ProjectServer/Projects?$select=Name,Id,IsCheckedOut

    Response is 200/OK. I happen to know there is only one project there, so I use the one at

    response.json().then(responseJSON => responseJSON.value[0])

    I store the ID to use later. If the project is not checked out, I proceed to check it out by sending POST to

    https://server/site/_api/ProjectServer/Projects('projectId')/checkout

    Response is 200/OK.

    I then try to delete tasks, and I have tried BOTH

    Sending DELETE to

    https://server/site/_api/ProjectServer/Projects('projectId')/Draft/Tasks('taskId')

    as described here, and also sending POST to

    https://server/site/_api/ProjectServer/Projects('projectId')/Draft/Tasks('taskId')/deleteObject()

    as described here. In BOTH cases I get back 200/OK.

    I then proceed to try to save the changes to the project by sending POST to

    https://server/site/_api/ProjectServer/Projects('projectId')/Draft/update

    Response is 200/OK. I then check in the project by sending POST to

    https://server/site/_api/ProjectServer/Projects('projectId')/Draft/checkin

    Response is 200/OK.

    That seems like a reasonable course of action:

    • Check out the project
    • Make changes to the draft project (deletes)
    • Update the project
    • Check in the project

    and for each of those steps the server is telling me it happened (200/OK).

    But then if I open the project in MS Project client, or get

    https://server/site/_api/ProjectServer/Projects('projectId')/Tasks

    then the tasks I thought I deleted are still there!

    What step am I missing to get my changes to stick?


    Dylan Cristy | MCSA: Web Applications

    Thursday, November 21, 2019 9:28 PM

All replies

  • Hi Dylan,

    Instead of simply checkin the project, try publish your changes and checkin the project, so your changes will be effected.

    Try this: after you update the project

    https://server/site/_api/ProjectServer/Projects('projectId')/Draft/publish(true)

    where "true" is force check-in.


    Rajkumar Allepu (MCP) , | https://sharepointprojectserver.com ** Please mark it as answer if my answer would resolved your issue.

    Friday, November 22, 2019 12:06 AM
  • Thanks for your answer Rajkumar, but in this case it is still not working.

    I am doing

    • Check out project
    • Delete tasks from /Project('id')/Draft/Task('id')
    • Update
    • Publish
    • Wait for queue job to be 100% complete / 0 WaitMilliseconds
    • Check in project

    Again, all with response 200/OK, but the tasks I tried to delete are still there.


    Dylan Cristy | MCSA: Web Applications


    Friday, November 22, 2019 4:01 PM
  • Hi,

    The update is a method so use it like a method.

    http://<sitecollection>/<site>/_api/ProjectServer/Projects('projectid')/Draft/update()

    refer the below URL for the right syntax related to update, publish and Check-in etc.. and try.

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


    Rajkumar Allepu (MCP) , | https://sharepointprojectserver.com ** Please mark it as answer if my answer would resolved your issue.

    Monday, November 25, 2019 10:50 AM
  • Nope, that doesn't help either.  And in any case, why should adding parentheses to make it look more like invoking a function/method make a difference?

    Since it's REST, wouldn't it be "invoked" just by hitting the endpoint?

    I mean, I can check the project out and check it back in by hitting

    /_api/ProjectServer/Project('projectId')/checkout

    and

    /_api/ProjectServer/Project('projectID')/Draft/checkin

    without the parentheses, and in between I can positively verify that the project is in a checked out state.  So if checkout and checkin work without adding parentheses, why would update need them?

    Another example, I can add tasks by checking out the project and hitting

    /_api/ProjectServer/Projects('projectId')/Draft/Tasks/Add

    without any parentheses there or having the parameters for the new task in the URL, but instead sending the parameters in the body of the request, even though the documentation here clearly shows that there is a "parameters" argument in parentheses:

    http://<sitecollection>/<site>/_api/ProjectServer/Projects('projectid')/Draft/Tasks/add(parameters)

    So while adding tasks, checking a project out, or checking it in, I do not add parentheses to make it seem like invoking a function, and yet it works.  So I don't think it's as simple as saying I need to add parentheses to the update call.


    Dylan Cristy | MCSA: Web Applications

    Monday, November 25, 2019 3:57 PM