How to import relationships

Hi all,

I want to move my blog about books to Storyblok. Each book has an author .

I’ve already manually created two components (author, book) as content types and also nestable.

Following Github’s CSV Import example, I’ve successfully imported authors (just name and slug)
Now, I think the key to import books together with its author is in these lines from the Management API:

The story[content] property needs to be an object at the root level
Every object inside needs to have the property “component”:“your_components_name”
Only nest components using arrays, except if you want to build a custom field type.
Every nested object which is a component or custom field type needs a _uid property.

So, the book story content should have this structure:

content: [
{

},
{
component: ‘author’
_uid: <author_uid>
}
]

My first problem is that I’m getting a 500 error in a single book import (setting the _uid manually) with this code.

The second problem is that I only have the slugs for the authors (not the _uids) in my book’s csv file.

What could be causing the 500 error? Am I using the right approach to import books and authors?

Thank you very much

Hello @fagudo,

when creating a more complex content structure with relations it is better to use the management API directly for creating the authors (Storyblok API Documentation). You can create the folder structure first in the UI and create one example story as an example and load it with the management API (Storyblok API Documentation) with its ID so you have a template for creating the next author stories.

The next step would be to get all UUIDs from the authors which can be done with this request Storyblok API Documentation and then you can create a blog or other entries of other content types as mentioned before as a template so you have the structure and add the UUIDs of these relations in the right places.

Best regards
Hannes