none
Programatically Creating Multiple Predecessors to one Task RRS feed

  • Question

  • Hi,



    I'm using the REST API with Project Web App (2016 patch 16.0.4351.1000), I'm trying to programatically add many predecessors to a single Task. My JSON payload looks like this:

    POST http://pwa-domain/PWA/_api/ProjectServer/Projects('e1606c03-346e-e611-80d3-0050568a983b')/Draft/TaskLinks/add
    {

      "parameters": {
        "__metadata": {},
        "DependencyType": "1",
        "StartId": "5f5b39c2-2f09-e911-80d3-0050568a983b",
        "EndId":   "605b39c2-2f09-e911-80d3-0050568a983b"
      }


    and the next request:

    POST http://pwa-domain/PWA/_api/ProjectServer/Projects('e1606c03-346e-e611-80d3-0050568a983b')/Draft/TaskLinks/add
    {

      "parameters": {
        "__metadata": {},
        "DependencyType": "1",
        "StartId": "5e5b39c2-2f09-e911-80d3-0050568a983b",
        "EndId":   "605b39c2-2f09-e911-80d3-0050568a983b"
      }


    However the second request overwrites the first one instead of adding an additional task link.



    I know you can do this through the user interface. If I add multiple predecessors manually, and then I perform the request afterwards I get this response with expected data:

    GET http://pwa-domain/PWA/_api/ProjectServer/Projects('e1606c03-346e-e611-80d3-0050568a983b')/TaskLinks?$expand=Start,End&$select=*,Start/Id,End/Id
    {
      "d": {
        "results": [
          {
            "__metadata": {
              "id": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('ccf5c8c3-3809-e911-80d3-0050568a983b')",
              "uri": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('ccf5c8c3-3809-e911-80d3-0050568a983b')",
              "type": "PS.PublishedTaskLink"
            },
            "End": {
              "__metadata": {
                "id": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('ccf5c8c3-3809-e911-80d3-0050568a983b')/End",
                "uri": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('ccf5c8c3-3809-e911-80d3-0050568a983b')/End",
                "type": "PS.PublishedTask"
              },
              "Id": "605b39c2-2f09-e911-80d3-0050568a983b"
            },
            "Start": {
              "__metadata": {
                "id": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('ccf5c8c3-3809-e911-80d3-0050568a983b')/Start",
                "uri": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('ccf5c8c3-3809-e911-80d3-0050568a983b')/Start",
                "type": "PS.PublishedTask"
              },
              "Id": "5e5b39c2-2f09-e911-80d3-0050568a983b"
            },
            "Id": "ccf5c8c3-3809-e911-80d3-0050568a983b",
            "DependencyType": 1
          },
          {
            "__metadata": {
              "id": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('cdf5c8c3-3809-e911-80d3-0050568a983b')",
              "uri": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('cdf5c8c3-3809-e911-80d3-0050568a983b')",
              "type": "PS.PublishedTaskLink"
            },
            "End": {
              "__metadata": {
                "id": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('cdf5c8c3-3809-e911-80d3-0050568a983b')/End",
                "uri": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('cdf5c8c3-3809-e911-80d3-0050568a983b')/End",
                "type": "PS.PublishedTask"
              },
              "Id": "605b39c2-2f09-e911-80d3-0050568a983b"
            },
            "Start": {
              "__metadata": {
                "id": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('cdf5c8c3-3809-e911-80d3-0050568a983b')/Start",
                "uri": "http://dev-msps436/PWA/_api/ProjectServer/Projects('e0606c03-346e-e611-80d3-0050568a983b')/TaskLinks('cdf5c8c3-3809-e911-80d3-0050568a983b')/Start",
                "type": "PS.PublishedTask"
              },
              "Id": "5f5b39c2-2f09-e911-80d3-0050568a983b"
            },
            "Id": "cdf5c8c3-3809-e911-80d3-0050568a983b",
            "DependencyType": 1
          }
        ]
      }
    }


    Can someone please guide me through the process of adding multiple predecessors.

    Thanks

    Ryan


    • Edited by rnosworthy Wednesday, December 26, 2018 11:21 PM
    Wednesday, December 26, 2018 6:17 PM