Expand my Community achievements bar.

AEM Assets API : Is it possible to migrate in bulk instead of single elements?

Avatar

Level 5

I would like to make a POST request to migrate elements in bulk. Can I do it in one API call instead of making multiple post request? Here's how my body looks like:

{
    "properties": {
        "description": "This is a Category Example",
        "title": "Category Example",
        "cq:model": "/conf/models/category",
        "elements": {
            "title": {
                "value": "Category-master",
                "variations": {
                    "en": {
                        "value": "Category English"
                    },
                    "es": {
                        "value": "Category Spanish"
                    }
                }
            },
            "uri": {
               "value": "Category-Uri-master",
                "variations": {
                    "en": {
                        "value": "Category uri English"
                    },
                    "es": {
                        "value": "Category uri Spanish"
                    }
                }
            },
            "id": {
               "value": "Category-id-master",
                "variations": {
                    "en": {
                        "value": "Category-id-master"
                    },
                    "es": {
                        "value": "Category-id-master"
                    }
                }
            }
        }
    }
}
5 Replies

Avatar

Community Advisor

@spidey1405 Yes ofcourse leveraging the power of Apache Sling, an open-source RESTful web framework that is part of Adobe Experience Manager's underlying technology stack.

 

https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-po...

 

you can form the post servlet url till the root path of where you would like to create the resources and post to AEM instance with basic authorizarion header of the user who has write access under the specific heirarchy.

Avatar

Level 5

The document that you shared looks a bit overwhelming to me. Can you share the example of request structure and the endpoint so that I could take that up and then make a requests?

Avatar

Community Advisor

POST URL:- https://AEMhost/content/poc -> root hierarchy under AEM Site Structure where page will be created.
POST Form Data:-
“:operation” : “import”
“:contentType” : “json”
“:name” -> String value, it is the name of the page in AEM and should be unique under a hierarchy.
“:content” :"REFER to below JSON"

 

SAMPLE JSON to which will create Page

{
"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "SAMPLE-AEM-Page-NAME",
"cq:template": "/conf/myproject/settings/wcm/templates/article-page",
"cq:contextHubSegmentsPath": "/etc/segmentation/contexthub",
"cq:conf": "/conf/myproject",
"sling:resourceType": "myproject/components/page",
"cq:contextHubPath": "/etc/cloudsettings/default/contexthub",
"root": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "myproject/components/container",
"container": {
"jcr:primaryType": "nt:unstructured",
"layout": "responsiveGrid",
"sling:resourceType": "myproject/components/container",
"article": {
"jcr:primaryType": "nt:unstructured",
"teaser": "SAMPLE-TEASER-TEXT",
"desc": "SAMPLE-DESCRIPTION-TEXT",
"title": "SAMPLE-TITLE-TEXT",
"sling:resourceType": "myproject/components/article"
}
}
}
}
}

Avatar

Level 5

Hey @Shashi_Mulugu the example JSON that you shared seems to be adding 1 page right? I wanted to know two things from you:

 

1. I need an example for multi element json

2. I need an example for content fragment rather than page.

Avatar

Community Advisor

what you can do is, create a folder testcontentfragments under /content/dam/ and create couple of CFs manually under the same path in your local AEM and use infinity.json or -1.json view to get the json of the parent folder like /content/dam/testcontentfragments.infinity.json and use similar json in the post request for new path.