Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

General discussion
  1. OpenProject
  2. Forums
  3. General discussion
  4. Is it possible to add relations by the API ?

Is it possible to add relations by the API ?

Added by Thomas Laurent almost 2 years ago

Hello,

I would like to add relations using the API.

Unfortunately, I see no post route for that in the documentation.

Is it possible ?

Thanks


Replies (2)

RE: Is it possible to add relations by the API ? - Added by Jens Ulferts almost 2 years ago

Hi Thomas, 

relations are currently always created by an endpoint nested under work_packages. This helps finding the work packages for which creating a relationship to is possible and also those for which a relationship to the work package already exists.

Therefore, the POST needs to be send to /api/v3/work_packages/:id/relations. The body still needs to contain the from and to for both work packages participating in the relation which, given the path, shouldn't be necessary. Be that as it may, the body should look something like:

{
  "_links":
    {
      "from": {
        "href":"/api/v3/work_packages/8717"
      },
      "to": {
        "href":"/api/v3/work_packages/8970"
      }
  },
  "type":"relates"
}

Hope that helps you.

Regards,

Jens

RE: Is it possible to add relations by the API ? - Added by Thomas Laurent almost 2 years ago

Jens Ulferts wrote:

Hi Thomas,

relations are currently always created by an endpoint nested under work_packages. This helps finding the work packages for which creating a relationship to is possible and also those for which a relationship to the work package already exists.

Therefore, the POST needs to be send to /api/v3/work_packages/:id/relations. The body still needs to contain the from and to for both work packages participating in the relation which, given the path, shouldn't be necessary. Be that as it may, the body should look something like:

{
  \"_links\":
    {
      \"from\": {
        \"href\":\"/api/v3/work_packages/8717\"
      },
      \"to\": {
        \"href\":\"/api/v3/work_packages/8970\"
      }
  },
  \"type\":\"relates\"
}

Hope that helps you.

Regards,

Jens

Oh, I've just look in the relations routes not in work_packages ones.

Thanks for your help Jens !

  • (1 - 2/2)
Loading...