Import Content

Introduction

Goal

Migrate content stored in a different CMS to Bloomreach Content using the Content Batch Import API.

Background

When coming from a different CMS, a lot of content might need to be migrated into Bloomreach Content.

Our goal is to support this use case and make it as easy as possible for developers to quickly migrate into Bloomreach Content.

We solve the migration of data problem by offering a Content Batch Import API. It enables developers to import large amounts of content into a Bloomreach project.

In this tutorial, we'll walk you through the process step by step with examples showing how to import content into Bloomreach Content. You can import both documents and/or pages in the batch request.

Step by Step Tutorial

1. Convert Your Content to Our Format

You can follow our detailed Recipe on what each field means on the batch import format.

In case you just want to see it working for yourself and quickly try out with some dummy content, here is an example:

{
    "type": "document",
    "contentType": "brxsaas:banner",
    "fields": [
        {
            "name": "title",
            "value": [
                "Our team is ready for your next product"
            ]
        },
        {
            "name": "content",
            "value": [
                "<p>example content</p>"
            ]
        },
        {
            "name": "image",
            "value": [
                "\/"
            ]
        },
        {
            "name": "cta",
            "value": [
                "Start your next project"
            ]
        },
        {
            "name": "link",
            "value": [
                "\/content\/documents\/brxsaas\/pages\/products\/all"
            ]
        }
    ],
    "name": "next-project11",
    "displayName": "Next Project11",
    "path": "\/content\/documents\/brxsaas\/banners\/next-project11"
}
{
    "type": "document",
    "contentType": "brxsaas:banner",
    "fields": [
        {
            "name": "title",
            "value": [
                "Brand 1"
            ]
        },
        {
            "name": "content",
            "value": [
                "<p>Sample content</p>"
            ]
        },
        {
            "name": "image",
            "value": [
                "\/content\/gallery\/brxsaas\/banners\/brand-1.jpg"
            ]
        },
        {
            "name": "cta",
            "value": []
        },
        {
            "name": "link",
            "value": [
                "\/content\/documents\/brxsaas\/pages\/products\/all"
            ]
        }
    ],
    "name": "brand-111",
    "displayName": "Brand 111",
    "path": "\/content\/documents\/brxsaas\/banners\/brand-111"
}
{
    "type": "page",
    "relativePath": "pages/home",
    "channelId": "brxsaas",
    "name": "home",
    "displayName": "Home",
    "layout": "two-column",
    "document": {
        "contentType": "brxsaas:content",
        "fields": [
            {
                "name": "title",
                "value": [
                    "My page"
                ]
            },
            {
                "name": "introduction",
                "value": [
                    "Sample introduction"
                ]
            },
            {
                "name": "content",
                "value": [
                    "Example page content"
                ]
            },
            {
                "name": "image",
                "value": [
                    "\/"
                ]
            },
            {
                "name": "date",
                "value": []
            }
        ]
    },
    "containers": [
        {
            "path": "top",
            "components": [
                {
                    "componentDefinition": "sample\/single-banner-carousel",
                    "componentConfigurations": [
                        {
                            "id": "DEFAULT",
                            "content": null,
                            "parameters": [
                                {
                                    "name": "alignment",
                                    "value": "center"
                                },
                                {
                                    "name": "document1",
                                    "value": "banners\/safe-workspace-1"
                                },
                                {
                                    "name": "document2",
                                    "value": "banners\/safe-workspace-2"
                                },
                                {
                                    "name": "interval",
                                    "value": "10000"
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "path": "main",
            "components": [
                {
                    "componentDefinition": "sample\/titleandtext",
                    "componentConfigurations": [
                        {
                            "id": "DEFAULT",
                            "content": {
                                "contentType": "titleandtext",
                                "fields": [
                                    {
                                        "name": "title",
                                        "value": [
                                            "Welcome to brX ContentX"
                                        ]
                                    },
                                    {
                                        "name": "text",
                                        "value": [
                                            "Welcome to the Bloomreach Sample Front-end Application for the brX Content."
                                        ]
                                    }
                                ]
                            },
                            "parameters": [
                                {
                                    "name": "titlesize",
                                    "value": "H3"
                                },
                                {
                                    "name": "textalignment",
                                    "value": "left"
                                },
                                {
                                    "name": "style",
                                    "value": "style1"
                                }
                            ]
                        }
                    ]
                },
                {
                    "componentDefinition": "sample\/titleandtext",
                    "componentConfigurations": [
                        {
                            "id": "DEFAULT",
                            "content": {
                                "contentType": "titleandtext",
                                "fields": [
                                    {
                                        "name": "title",
                                        "value": [
                                            ""
                                        ]
                                    },
                                    {
                                        "name": "text",
                                        "value": [
                                            "We have tried to keep it as clean, effective and simple as possible"
                                        ]
                                    }
                                ]
                            },
                            "parameters": [
                                {
                                    "name": "titlesize",
                                    "value": "H3"
                                },
                                {
                                    "name": "textalignment",
                                    "value": "left"
                                },
                                {
                                    "name": "style",
                                    "value": "style1"
                                }
                            ]
                        }
                    ]
                },
                {
                    "componentDefinition": "sample\/category-highlight",
                    "componentConfigurations": [
                        {
                            "id": "DEFAULT",
                            "content": {
                                "contentType": "CategoryHighlight",
                                "fields": [
                                    {
                                        "name": "title",
                                        "value": [
                                            "Highlight categories"
                                        ]
                                    },
                                    {
                                        "name": "connectorid",
                                        "value": [
                                            "brsm"
                                        ]
                                    },
                                    {
                                        "name": "CommerceCategoryCompound",
                                        "value": [
                                            {
                                                "fields": {
                                                    "categoryid": [
                                                        "PNB160400000000"
                                                    ]
                                                }
                                            },
                                            {
                                                "fields": {
                                                    "categoryid": [
                                                        "PNB160402010000"
                                                    ]
                                                }
                                            },
                                            {
                                                "fields": {
                                                    "categoryid": [
                                                        "PNB160401010000"
                                                    ]
                                                }
                                            },
                                            {
                                                "fields": {
                                                    "categoryid": [
                                                        "PNB250800000000"
                                                    ]
                                                }
                                            }
                                        ]
                                    }
                                ]
                            },
                            "parameters": []
                        }
                    ]
                }
            ]
        }
    ]
}

2. Get Project ID

The content is always imported via a specific development project. This constraint is to guarantee that all operations are performed without having any chances of affecting the live website, being all writes performed on the unpublished variant of a page or document associated with the development project.

Therefore the first step is to have a project and then retrieve the project_id via the API.

Use the endpoint Get all channels.

{
  ...,
  "branch": "vIUy9",
  ...
}

The branch parameter is what you'll need to trigger the content import.

3. Create Content in a Specific Project

Send a POST request to the endpoint Create content (documents and pages) in a specific project

When sending the content, no validation is performed against the content model.

4. Check the Status of the Import via API

First you need to get a list of all operations that were triggered via List all operations. This will return a list of UUID that represent the jobs that are running

Then, you can get the details of each of the jobs using the Get operation details endpoint.

{
  "operationId": "0f68c6d9-cfee-49ac-9cff-6d82d34ee704",
  "projectId": "vI8Xo",
  "status": "COMPLETED",
  "readCount": 6,
  "writeCount": 5,
  "skipCount": 1,
  "startTime": "[email protected]:47:00.448+0000",
  "endTime": "[email protected]:47:08.632+0000",
  "errorLog": [
    {
      "path": "pages/home",
      "error": "Item not found; nested exception is javax.jcr.ItemNotFoundException: Component definition 'hst:components/sample/single-banner-carouselZ' not found"
    }
  ]
}

5. Check the Imported Content via the UI

In the development project you can preview the imported pages and documents and approve them so that a merge can be done.

6. Merge the Project

When merging the development project, all the imported content will be published into Core.

Error Handling

In case something goes wrong during the batch import process, there is the option of deleting the project before it's merged and trying again from scratch in a new development project.


Did this page help you?