Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Manipulating Content - The SlingPostServlet (servlets.post) | AEM Community Blog Seeding

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,157 likes

Total Posts

6,247 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,157 likes

Total Posts

6,247 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

01-06-2021

BlogImage.jpg

Manipulating Content - The SlingPostServlet (servlets.post) by sling.apache.org

Abstract

Multiple Ways to Modify Content
As always in life there is more than one way to do it. So to modify content in Sling, you have multiple options, the Sling default POST Servlet also called the SlingPostServlet is one of them. This page is about how you can modify - create, modify, copy, move, delete, import - content through the SlingPostServlet. In addition it also explains how to extend the SlingPostServlet with new operations.

Quickstart: Creating Content
To create content you simply send an HTTP POST request using the path of the resource to store the content in and include the actual content as request parameters. So one possibility to do just that is by having an HTML Form like the following:
This simple form will set the title and text properties on a resource at /some/new/content. If this resource does not exist it is just created otherwise the existing content would be modified.

Similarly, you can do this using the curl command line tool:

$ curl -Ftitle="some title text" -Ftext="some body text content" http://host/some/new/content
You might want to set a specific Sling resource type using the sling:resourceType property:

$ curl -F"sling:resourceType=sling:sample" -Ftitle="some title text" \
-Ftext="some body text content" http://host/some/new/content
If you deal with a JCR repository you might want to set the node type (however using Sling resource type is the preferred way):

$ curl -F"jcr:primaryType=nt:unstructured" -Ftitle="some title text" \
-Ftext="some body text content" http://host/some/new/content
Similarly, you may assign JCR mixin node types using the jcr:mixinTypes property.

Read Full Blog

Manipulating Content - The SlingPostServlet (servlets.post)

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager