Hi @SarveshPalani ,
The HTTP API for creating a Content Fragment in AEM returns a 200 status code with a "Content modified" message instead of a 201 status code with a "Content created" message. This is because the API is designed to update an existing Content Fragment if it already exists at the specified path, or create a new one if it does not exist.
In your case, it seems that the Content Fragment was not created because the path specified in the API call already exists. You can verify this by checking if the Content Fragment already exists at the specified path.
To ensure that the Content Fragment gets created, you can modify the API call to use a unique path that does not already exist. For example, you can append a timestamp or a random string to the path to ensure uniqueness.
Here's an example of how you can modify the API call to use a unique path:
URL: https://{{bucket}}.adobeaemcloud.com/api/assets/myproject/new-cf-{{timestamp}}
In this example, we append the current timestamp to the path to ensure uniqueness.
Alternatively, you can use the PUT method instead of the POST method to create the Content Fragment. The PUT method is idempotent, which means that it can be used to create or update a resource. If the resource already exists, it will be updated, and if it does not exist, it will be created.
Here's an example of how you can use the PUT method to create a Content Fragment:
URL: https://{{bucket}}.adobeaemcloud.com/api/assets/myproject/new-cf
Method: PUT
Body:
{
"properties": {
"description": "New Content Fragment Description",
"title": "New Content Fragment",
"name": "new-cf",
"cq:model": "/conf/myproject/settings/dam/cfm/models/samplemodel",
"elements": {
"title": {
"value": "Test Title for Content Fragment"
}
}
}
}
Using the PUT method ensures that the Content Fragment is created if it does not exist, and updated if it already exists.