Troubles when creating items using modular content

Hello,
I try to use the API to create an item like this :

const record = await client.items.create({
    type: "item",
    relationships: { item_type: { data: { type: "item_type", id: "1010" } } },
    attributes: {
      description: "test3",
      data: {
        fr: [
          {
            relationships: {
              item_type: { data: { type: "item_type", id: "2020" } },
            },
            type: "item",
            attributes: {
              label: "test",
            },
          },
        ],
        en: [
          {
            relationships: {
              item_type: { data: { type: "item_type", id: "2020" } },
            },
            type: "item",
            attributes: {
              label: "test",
            },
          },
        ],
        es: [
          {
            relationships: {
              item_type: { data: { type: "item_type", id: "2020" } },
            },
            type: "item",
            attributes: {
              label: "test",
            },
          },
        ],
        de: [
          {
            relationships: {
              item_type: { data: { type: "item_type", id: "2020" } },
            },
            type: "item",
            attributes: {
              label: "test",
            },
          },
        ],
        it: [
          {
            relationships: {
              item_type: { data: { type: "item_type", id: "2020" } },
            },
            type: "item",
            attributes: {
              label: "test",
            },
          },
        ]
      },
    },
  });

I get an error 422 Unprocessable Entity :

[
{
“id”: “2431af”,
“type”: “api_error”,
“attributes”: {
“code”: “INVALID_FORMAT”,
“details”: {
“messages”: [
“#/data: failed schema #/definitions/item/links/3/schema/properties/data: "relationships" wasn’t supplied.”
]
}
}
}
]

But all relationships are provided.

I need some help :slight_smile: thank you

Hello @kevin.zid and welcome to the community!

If you are using the Javascript client to create a block, you need to use the buildBlockRecord as documented here: Create a new record - Record - Content Management API

Perhaps you are following the “HTTP” documentation for the creation of blocks instead? On the top of the documentation page you can see:

thank you :slight_smile: yeah you right, my bad