Describe the issue:
I’m trying to migrate data from another cms to DatoCMS. The models I want to migrate data to have to contain some blocks like this one:
The AccordianList has ID 2784630
I have read the internet to the end without finding any answer on how to do this
My code looks like this:
try {
const article = {
item_type: {
type: "item_type",
id: itemTypeArticle
},
title: child.title,
body,
slug: child._slug,
seo: {
title: "seo tittel",
description: "seo beskrivelse",
}
};
...
} ....
and the body object looks like this:
const body = {
"schema": "dast",
"document": {
"type": "root",
"children": [
{
"item": "2784630",
"type": "block"
},
{
"level": 2,
"children": [
{
"value": "Hva er spillegrenser?",
"type": "span"
}
],
"type": "heading"
},
{
"children": [
{
"value": "Spillegrense er en personlig grense for hvor mye penger du kan tape på pengespill hos Norsk Tipping i løpet av en dag eller en måned.",
"type": "span"
}
],
"type": "paragraph"
},
]
},
}
The error I get is this:
Error: POST https://site-api.datocms.com/items: 422 Unprocessable Content
[
{
"id": "ff3436",
"type": "api_error",
"attributes": {
"code": "INVALID_FIELD",
"details": {
"field": "body",
"code": "INVALID_FORMAT",
"message": "Cannot use IDs instead of block records objects when creating an Item"
}
}
}
]
Can anyone please tell me how to do this the correct way?
(Moderator note: Fixed code formatting)