How retrieve space history using the REST API

I’m trying to retrieve the last modified date of spaces and pages using the history.lastUpdated expand. For pages it’s working, but for spaces that expand is not returned. Is it possible to retrieve the space history?

Request for pages:
http://localhost:8090/rest/api/content/12345678?expand=space,history.lastUpdated
it returns a history section

Request for space:
http://localhost:8090/rest/api/space/MYSPACE?expand=history.lastUpdated
it returns:

{
    "_expandable": {
        "description": "",
        "homepage": "/rest/api/content/22052915",
        "icon": "",
        "metadata": ""
    },
    "_links": {
        "base": "http://localhost:8090",
        "collection": "/rest/api/space",
        "context": "",
        "self": "http://localhost:8090/rest/api/space/MYSPACE",
        "webui": "/display/MYSPACE"
    },
    "id": 22085636,
    "key": "MYSPACE",
    "name": "my-space",
    "type": "global"
}

Is there another expand that can be used for this case?

Hello @diego.guiterrez,

Welcome to the Developer Community!

To get started, please correct me if I’m wrong, but I think your category is incorrect - instead of Category Jira Development and Jira Server I think you want it to be Confluence Development and Confluence Server.

Going back to your question, /rest/api/space does not have a history option for expand (as you might have noticed in "_expandable" options). If you’re mostly interested with the last updated date value, you can use /rest/api/search?cql=space.key=MYSPACE and checkout the lastModified in space.

Cheers,
Ian

1 Like

Thank you very much, this query is returning the last modified date:

http://localhost:8090/rest/api/search?cql=space.key=MYSPACE+AND+type=space

(I also change the category to Confluence development)

You’re welcome, @diego.guiterrez. Adding the type in your CQL is a nice touch.