How to create a child work package with API in OpenProject

In docu. There is an example how to create some kind of relation between packages but there is nothing about creating a parent child relation. Maybe someone knows how to do this?

I will post a screen shot when I get to my pc.

This is what is available in the docu:

enter image description here

and these are the only available relations:

enter image description here

How to make the Parent <-> Child relation so that it looks like this in open project:

enter image description here

1 answer

  • answered 2018-04-17 05:40 ulferts

    Although parent-child relations are in fact relations (conceptually and in the db), they are not treated as such in the API (mostly for historic reasons).

    Therefore, one needs to set the parent via the work package resource. A minimal payload on a PATCH to /api/v3/work_packages/:id (the work package to become the child) would look like this:

    {
      "lockVersion": [the correct version],
      "_links": {
        "parent": {
          "href": "/api/v3/work_packages/[ID of the work package to become the parent]"
        }
      }
    }
    

    Edit

    There is actually an example in the API documentation. You need to open the "Request" example for the PATCH to `/api/v3/work_packages/:id to see it, though.