Getting last node id with REST API

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

Getting last node id with REST API

Hi,

 

I'm using rest API and I'm able to work with nodes as soon as I have his ID ..

but in that new case I would like to retrieve, with the REST API, the doc id of the last document that has been created

Could someone help achieve this result ?

 

thnaks !

1 Reply
fedorow
Senior Member II

Re: Getting last node id with REST API

The request for Search API is:

curl -X POST "http://localhost/alfresco/api/-default-/public/search/versions/1/search" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"query\": {    \"language\": \"afts\",    \"query\": \"TYPE:'cm:content'\"  },  \"paging\": {    \"maxItems\": 1,    \"skipCount\": 0  },  \"sort\": [    {      \"type\": \"FIELD\",      \"field\": \"cm:created\",      \"ascending\": false    }  ]}"

The query from this request is:

{
  "query": {
    "language": "afts",
    "query": "TYPE:'cm:content'"
  },
  "paging": {
    "maxItems": 1,
    "skipCount": 0
  },
  "sort": [
    {
      "type": "FIELD",
      "field": "cm:created",
      "ascending": false
    }
  ]
}

It's just a draft for the direction to moving on. Check the properties and make a closer query string.