Open link in a new tab

Content

Expand project menu

Filtering list of projects using the apis

Greetings, 

I'm trying to filter projects by a custom filter I defined. Is this possible or is it an enterprise edition feature? I get an error message saying the filter doesn't exist. 

same goes for a built-in filter principal which is listed among the default filters in the api documentation yet I get the same message when I use it. 

here is my sample request:

/api/v3/projects?filters=[{ "principal": { "operator": "=", "values": ["hassan "] }}]

btw, I'm using the community edition.

Message actions

Hi Hassan,

the principal filter on projects acts as a filter of memberships. The filter value needs to be the principal ID (e.g., user ID), not a string value. It is available in all editions of OpenProject.

For example, to see all projects I'm member of (this will be empty for unauthorized users without the view_members permission)

https://community.openproject.com/api/v3/projects?filters=[{ "principal": { "operator": "=", "values": ["9177"] }}]

Best

Oliver

Message actions

Oliver Günther wrote:

Hi Hassan,

the principal filter on projects acts as a filter of memberships. The filter value needs to be the principal ID (e.g., user ID), not a string value. It is available in all editions of OpenProject.

For example, to see all projects I'm member of (this will be empty for unauthorized users without the view_members permission)

https://community.openproject.com/api/v3/projects?filters=[{ \"principal\": { \"operator\": \"=\", \"values\": [\"9177\"] }}]

Best

Hey Oliver, thanks for the reply

still I get the same error even after I put an ID in the values list 

{
    "_type": "Error",
    "errorIdentifier": "urn:openproject-org:api:v3:errors:InvalidQuery",
    "message": [
        "Filters Principal does not exist."
    ]
}

is there some API configuration I'm missing? and how about the custom fields? can I filter by them? 

I also want to ask about the memberships endpoint, I get 404 when I request it .. is it enterprise edition only or what?

Message actions

Are you perhaps using an older version of OpenProject?

Best,

Oliver

Message actions

I'm using 8.1 , but the api is v3 , it should be the same regardless of open project version right? 

Oliver Günther wrote:

Are you perhaps using an older version of OpenProject?

Best,

Oliver

Message actions

No that's not the case. You need to update since project API was added later. APIv3 is not complete yet and there will be new additions in releases.

Message actions

and will we be able to filter by custom fields in the new version? 

Oliver Günther wrote:

No that's not the case. You need to update since project API was added later. APIv3 is not complete yet and there will be new additions in releases.