Top Menu

Jump to content
    Global modules

    Global modules

    • Home
    • Projects
    • Activity
    • Work packages
    • Gantt charts
    • Calendars
    • Team planners
    • Boards
    • News
    Home
    Home
Help
    Getting started
    • Introduction video
  • 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

User menu

Sign in
Forgot your password?

or sign in with your existing account

OpenProject ID Google

Side Menu

Collapse project menu

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

Content

Expand project menu
Development
  1. OpenProject Community
  2. OpenProject
  3. Forums
  4. Development
  5. Project hierarchy from API

Project hierarchy from API

Added by Carlos Lacasta over 7 years ago

I have projects with sub-projects and I do not see in the API v3 documentation an easy way to get the project hierarchy. I tried with the ancestor query but gives me an internal error

curl -g -u apikey:XXXX https://the_server/api/v3/projects?filters=[{ancestor

gives

{_type internal error has occured.“}{”_type“:”Error“,”errorIdentifier“:”urn:openproject-org:api:v3:errors:InternalServerError“,”message“:”An internal error has occured."}

Am I doing something wrong ?


Replies (4)

RE: Project hierarchy from API - Added by Jens Ulferts over 7 years ago

Hi Carlos,

try

curl -g -u apikey:XXXX https://the_server/api/v3/projects?filters='[{"ancestor":{"operator":"=","values":["19"]}}]'

1) the filters where missing a second closing curly brace (})
2) the filters value needs to be a dumped json object, which basically means having quotation marks around the value

Regards

Jens

RE: Project hierarchy from API - Added by Carlos Lacasta over 7 years ago

thanks Jens !!

I am still getting the same error, which makes me think it has to do with your point 2). I thought the value is the project ID who is the ancestor of the subproject I want to get (it is at least what I understood from the example in the API doc.). Shouldn’t I get from the above the list of projects under project with id=19 ?

Cheers,

Carlos

RE: Project hierarchy from API - Added by Jens Ulferts over 7 years ago

Yes, once the request is correct, you will get the list of projects that are descendantes of the project provided as a filter value.

I assume that you do still have a typo in your curl command as what I posted even works agains e.g. community.openproject.com.

Can you please post your current command again so I can double check?

RE: Project hierarchy from API - Added by Carlos Lacasta over 7 years ago

My fault… Sorry. Now it works.

Many thanks !

Carlos

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