Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,740
Community Members
 
Community Events
165
Community Groups

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

Edited

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 Community Leader Jun 02, 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 

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 Community Leader Jun 06, 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

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 Community Leader Jun 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

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 Community Leader Jun 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
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

316 views 2 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you