Rest API, How to getChildren and orderBy a properties

cancel
Showing results for 
Search instead for 
Did you mean: 
danny36
Active Member

Rest API, How to getChildren and orderBy a properties

Jump to solution

Hello,

I need if possibile to order a list of nodes returned from getChildren api call by one of a properties.

In the rest api doc it is not mentioned.

 

thanks.

1 Solution

Accepted Solutions
angelborroy
Alfresco Employee

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

This is working for me:

http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/8bb36efb-c26d-4d2b-9199-ab6922f53c28/children?skipCount=0&maxItems=100&orderBy=cm%3Atitle

 

I guess you can use the same approach with your custom property name wbase%3AcognomeRubrica

Hyland Developer Evangelist

View solution in original post

9 Replies
angelborroy
Alfresco Employee

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

Did you try the "orderBy" parameter?

https://api-explorer.alfresco.com/api-explorer/#/nodes/listNodeChildren

Hyland Developer Evangelist
danny36
Active Member

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

in the doc the available orderBy fields are:

  • isFolder
  • name
  • mimeType
  • nodeType
  • sizeInBytes
  • modifiedAt
  • createdAt
  • modifiedByUser
  • createdByUser

but I need to order by a property inside "properties"

 

Annotazione 2021-10-22 105812.png

angelborroy
Alfresco Employee

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

This is working for me:

http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/8bb36efb-c26d-4d2b-9199-ab6922f53c28/children?skipCount=0&maxItems=100&orderBy=cm%3Atitle

 

I guess you can use the same approach with your custom property name wbase%3AcognomeRubrica

Hyland Developer Evangelist

View solution in original post

danny36
Active Member

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

yes it works!

I think it is a serious shortcoming that such an important thing is not indicated in the documentation.

Anyway thanks!!!

danny36
Active Member

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

Hi,

and if I want to retrive a set of items based on a property inside properties? I tray filter:

where=(wbase%3AtipologiaRubrica=1)

but don't works.

angelborroy
Alfresco Employee

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

Where filter is not designed to accept that kind of expressions. Mainly Where syntax is described in

https://github.com/Alfresco/alfresco-community-repo/blob/master/remote-api/src/main/java/org/alfresc...

You need to use Search REST API in order to apply filters based in custom properties.

Hyland Developer Evangelist
angelborroy
Alfresco Employee

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

For instance, this REST API call will retrieve all the children from a parent folder (ANCESTOR) having the property cm:title with "Title" value:

curl --location --request POST 'http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search' \
--header 'Authorization: Basic YWRtaW46YWRtaW4=' \
--header 'Content-Type: application/json' \
--data-raw '{
  "query": {
    "query": 
    "ANCESTOR:'\''workspace://SpacesStore/0f90a538-10d3-4f3f-9a9c-431e674a4f89'\'' AND cm:title:'\''Title'\''"
  }
}'
Hyland Developer Evangelist
danny36
Active Member

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

unfortunately it does not seem to be possible to search a term inside properties property.

angelborroy
Alfresco Employee

Re: Rest API, How to getChildren and orderBy a properties

Jump to solution

It's possible, but using the Search REST API with ANCESTOR.

Hyland Developer Evangelist