Import linked content
Content items often contain references to other content items in linked items elements or rich text elements. This lesson shows you how to import these references to Kontent.ai.
How to think about links between your content
To avoid having to import objects in a specific order, use external IDs to reference content that’s not yet imported. This solves problems with circular dependencies and lets you reference non-existent content. Here is how it works:- Define external IDs for all content items and assets you want to import in advance.
- When referencing another content item or asset, use its external ID.
- Import your content using the upsert methods with an external ID. The system will resolve all references.
Example scenario
Say you want to import two related content items: Donate with us and On Roasts articles. Each content item references the other in the Related articles Linked items element. The result will have the following structure:1. Define external IDs
External IDs are string-based identifiers of items and assets defined by you. You can define new IDs or reuse IDs from the original storage system you are importing content from. It's up to you to ensure no two objects have the same external ID. See more details on using external IDs for imported content. For large projects, consider using GUIDs. To keep things simple here, use123
and 456
for your two articles.
2. Use external IDs to reference items
When defining the Linked items elements, use external IDs to reference the other content item:"related_articles": [
{
"external_id": "456"
}
]
3. Import content
To create a content item, send a PUT request to the/items/external-id/<YOUR_ITEM_EXTERNAL_ID>
endpoint.
In the body of the request, specify the item's name and content type.
See more details on upserting content items.
Second content item
Repeat the same process with the Donate with us article. Start by creating the content item:Validate imported content
Sign in with your Kontent.ai credentials or sign up for free to unlock the full lesson, track your progress, and access exclusive expert insights and tips!