在内容丰富文本中创建嵌入式块条目

时间:2020-08-26 16:45:13

标签: c# .net contentful richtext contentful-management

我无法使用.NET Contentful SDK 5.0.0在RTF文本字段中创建嵌入式条目。

var entry = new Block()
        {
            NodeType = "embedded-entry-block",
            Data = new BlockData()
            {
                Target = new Contentful.Core.Models.Management.ReferenceProperties()
                {
                    LinkType = "Entry",
                    Id = "2eUs1oo4fV4CuMgi57tycX"
                }
            }
        };

根据Contentful Api Documentation,Block应该具有BlockData类型的Data属性。 BlockData具有Target属性,该属性应为ReferenceProperties类型。这些ReferenceProperty应该具有LinkType和ID,如您在上面的代码中看到的那样,该ID已提供。

但是当我尝试运行代码时,它会抛出:

    Validation error[
  {
    "name": "unexpected",
    "details": "The property \"type\" is not expected",
    "path": [
      "fields",
      "text",
      "de",
      "content",
      0,
      "data",
      "target",
      "type"
    ]
  },
  {
    "name": "unexpected",
    "details": "The property \"linkType\" is not expected",
    "path": [
      "fields",
      "text",
      "de",
      "content",
      0,
      "data",
      "target",
      "linkType"
    ]
  },
  {
    "name": "unexpected",
    "details": "The property \"id\" is not expected",
    "path": [
      "fields",
      "text",
      "de",
      "content",
      0,
      "data",
      "target",
      "id"
    ]
  },
  {
    "name": "required",
    "details": "The property \"sys\" is required here",
    "path": [
      "fields",
      "text",
      "de",
      "content",
      0,
      "data",
      "target",
      "sys"
    ]
  },
  {
    "name": "required",
    "details": "The property \"content\" is required here",
    "path": [
      "fields",
      "text",
      "de",
      "content",
      0,
      "content"
    ]
  }
]

我错过了什么吗?为此,Block绝对是正确的课程吗?

我也在EntryStructure类上尝试过,但是没有用。

0 个答案:

没有答案