How do I get the lastModified date to be returned in the JSON response?

ian.kleinfeld May 31, 2022

I'm trying to get the actual DATE for the last modification, not just results that fit in that constraint, i.e., 

rest/api/content/search?cql=lastModified>=2022-01-02&expand=body.storage,history,history.lastModified

Doesn't seem to make a difference if I quote the date or not "2022-01-02" or 2022-01-02. 

Results are not including lastModified, and I'm unable to find where to get it in the documentation. There is no detail about it in https://developer.atlassian.com/server/confluence/cql-field-reference/#lastmodified

 Is it even a history.property? I can't find that either. 

Thanks!

@Shannon S I saw you've answered questions like this before. 

1 answer

0 votes
Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 2, 2022

Hi @ian.kleinfeld 

Do I understand you correctly when I say, the REST call returns the correct pages, but you are unable to get the lastModification date in the anwser? 

Try with "expand=version".

Then you will get 

"version":{
"by":{
...
},
"displayName":"...",
"_links":{
...

},
"_expandable":{
"status":""
}
},
"when":"2022-06-02T08:07:06.000+02:00",
"number":1,
"minorEdit":false,
"hidden":false,

In the "when", this is the last modification date.

Regards, Dominic 

ian.kleinfeld June 6, 2022

Thank you. I'm VERY new to CQL.

expand=version works by itself:

cql=space.type=global&text=care&expand=version
"version": {
"by": {
"type": "known",
"username": "mieak",
"userKey": "5617289345jggfajf89a3",
"profilePicture": {
"path": "/images/icons/profilepics/default.svg",
"width": 48,
"height": 48,
"isDefault": true
},
"displayName": "Michales, Miek (MM)",
"_links": {
"self": "https://wiki.mysite.com/rest/api/user?key=asdafebq34905"
},
"_expandable": {
"status": ""
}
},
"when": "2011-11-19T22:18:38.000-06:00",
"message": "This version of the page was created by the system as a result of upgrading to Confluence 5.8 on Fri Apr 1 18:39:39 CDT 2016 The contents of the page have not changed.",
"number": 1,
"minorEdit": false,
"hidden": false,
"_links": {
"self": "https://wiki.mysite.com/rest/experimental/content/6585414791/version/1"
},
"_expandable": {
"content": "/rest/api/content/6585414791"
}
},

 

but not when added to, for example 

cql=space.type=global&type=attachment&text=care&expand=body.view,history,history.lastUpdated,version

Gives me this, which has, I think lastUpdated.when, which I think should suffice, am I right? But I'm not getting the version expanded. 

 

{
"id": "1085643280",
"type": "comment",
"status": "current",
"title": "Title to a great article",
"history": {
"lastUpdated": {
"by": {
"type": "anonymous",
"profilePicture": {
"path": "/s/-d9vrmd/0504/1rcy8jf/_/images/icons/profilepics/anonymous.svg",
"width": 48,
"height": 48,
"isDefault": true
},
"displayName": "Anonymous"
},
"when": "2012-07-10T18:51:53.000-05:00",
"message": "This version of the page was created by the system as a result of upgrading to Confluence 5.8 on Fri Apr 1 18:39:39 CDT 2016 The contents of the page have not changed.",
"number": 1,
"minorEdit": false,
"hidden": false,
"_links": {
"self": "https://wiki.mysite.com/rest/experimental/content/1078003280/version/1"
},
"_expandable": {
"content": "/rest/api/content/1085643280"
}
},
"latest": true,
"createdBy": {
"type": "anonymous",
"profilePicture": {
"path": "/s/-d9vrmd/8703/1scy8jf/_/images/icons/profilepics/anonymous.svg",
"width": 48,
"height": 48,
"isDefault": true
},
"displayName": "Anonymous"
},
"createdDate": "2012-07-10T18:51:52.000-05:00",
"_links": {
"self": "https://wiki.mysite.com/rest/api/content/1085643280/history"
},
"_expandable": {
"previousVersion": "",
"contributors": "",
"nextVersion": ""
}
},
"body": {
"storage": {
"value": "<p>this window is too far to the right i cannot view the whole page , and there seems to be no way to scroll to the right hand edge of this window. I have seen this problem with ALL of the Learning videos so far</p>\n\n<p>Bob</p>",
"representation": "storage",
"_expandable": {
"content": "/rest/api/content/1085643280"
}
},
"_expandable": {
"editor": "",
"view": "",
"export_view": "",
"styled_view": "",
"anonymous_export_view": ""
}
},
"extensions": {
"location": "footer",
"_expandable": {
"resolution": ""
}
},
"_links": {
"webui": "/display/AHAUTX/Uncharting+in+I-View+QuickDemo?focusedCommentId=1078003280#comment-1078003280",
"self": "https://wiki.mysite.com/rest/api/content/1085643280"
},
"_expandable": {
"container": "/rest/api/content/1085643280",
"metadata": "",
"operations": "",
"children": "/rest/api/content/1085643280/child",
"restrictions": "/rest/api/content/1085643280/restriction/byOperation",
"ancestors": "",
"version": "",
"descendants": "/rest/api/content/1085643280/descendant",
"space": "/rest/api/space/ABCD"
}
},

 

Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 6, 2022

In this case, I would suggest to you:

  • Just getting the content ID and make another call for every ID to get the details of this page.

Regards, Dominic

ian.kleinfeld June 7, 2022

Thanks, Dominic. Would you show me how that would look? I literally am BRAND NEW to cql and am unsure how to do that yet. 

Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 12, 2022

Can you tell me what you are trying to achieve and in which language you did this till now? 

I'm using Python and do the rest calls. With python you will be able to make for loops with the rest calls. 

Regards, Dominic

ian.kleinfeld June 14, 2022

Hi Dominic, I'm literally just trying to come up with a built url that gets everything I need in the browser. I just do a REST call from Freemarker to get it. 

So, while I was able to get lastUpdated.when in this call above, I am now curious why I can't get the version expansion added to that REST call?

Thanks,

 

Ian

Dominic Lagger
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 14, 2022

I think this just does not work.

Either you will get the lastUpdated.when or the other. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events