set cq:lastModified using curl command | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
ShubhanshuSi2Accepted solution
New Participant
Jun 16, 2023 6:23 PM UTC

@hello299 . You may use Sling Post Servlet to update properties by POST call to jcr:content path. You may import the below curl command(update auth headers if needed) into Postman and execute it for batch if required.

 

curl --location --request POST 'http://localhost:4502/content/xyz/language/en-us/abc/pqr/jcr:content' \ --header 'Authorization: Basic YWRtaW46YWRtaW4=' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'cq:lastModified=2018-05-11T11:45:03.673+05:30' \ --data-urlencode 'cq:lastModified@TypeHint=Date'

 

But there is an observation when you update cq:lastModified property via Sling Post, it updates the property back again to current modified timestamp. AFAIK, you have to do some custom script development for your correction and use that endpoint.

 

ResourceResolver resourceResolver = request.getResourceResolver(); Resource resource = resourceResolver .getResource("<pagepath>/jcr:content"); ModifiableValueMap modifiableValueMap = resource.adaptTo(ModifiableValueMap.class); modifiableValueMap.put("cq:lastModified", <date value>); resourceResolver.commit();

 

 

6 replies

Tanika02
Level 7
Jun 18, 2023 5:20 PM UTC

Hello @hello299 

 

You can use below CURL command to set cq:lastModified (2018-02-21T15:24:18.000Z) using curl command for a particular page.

 

curl -u admin:admin -X POST \
-H "Content-Type: application/json" \
-d '{"cq:lastModified": "2018-02-21T15:24:18.000Z"}' \
http://localhost:4502/content/we-retail/us/en/men/jcr:content

Translate
Shashi_Mulugu
New Participant
Jun 18, 2023 1:39 AM UTC

@hello299 no you can't change internal properties such as modified or created dates using any commands or controls.. they are managed by AEM/Sling/JCR. May I know what's your requirement behind this? May be we can guide better..

Translate
joerghoh
Employee
Jun 18, 2023 3:36 PM UTC

of course you can change cq:lastModified. It's nothing special about this property.

Translate
aanchal-sikka
New Participant
Jun 17, 2023 7:21 AM UTC

Curl command to add a property to a page is 

     curl -u admin:admin -FnavRoot="true" http://localhost:4502/content/we-retail/us/en/jcr:content

Here navRoot is property name and true is the value.

 

Translate
Aanchal Sikka
ShubhanshuSi2Accepted solution
New Participant
Jun 16, 2023 6:23 PM UTC

@hello299 . You may use Sling Post Servlet to update properties by POST call to jcr:content path. You may import the below curl command(update auth headers if needed) into Postman and execute it for batch if required.

 

curl --location --request POST 'http://localhost:4502/content/xyz/language/en-us/abc/pqr/jcr:content' \ --header 'Authorization: Basic YWRtaW46YWRtaW4=' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'cq:lastModified=2018-05-11T11:45:03.673+05:30' \ --data-urlencode 'cq:lastModified@TypeHint=Date'

 

But there is an observation when you update cq:lastModified property via Sling Post, it updates the property back again to current modified timestamp. AFAIK, you have to do some custom script development for your correction and use that endpoint.

 

ResourceResolver resourceResolver = request.getResourceResolver(); Resource resource = resourceResolver .getResource("<pagepath>/jcr:content"); ModifiableValueMap modifiableValueMap = resource.adaptTo(ModifiableValueMap.class); modifiableValueMap.put("cq:lastModified", <date value>); resourceResolver.commit();

 

 

Translate