How to set cq:lastModified (2018-02-21T15:24:18.000Z) using curl command for a particular page eg(http://localhost:4502/content/xyz/language/en-us/abc/pqr/jcr:content)
Solved! Go to Solution.
Views
Replies
Total Likes
@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();
@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();
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.
@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..
of course you can change cq:lastModified. It's nothing special about this property.
Replication On Modification is enabled but versioning on replication is not disabled.
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
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies