使用Content-Management-API在内容丰富的空间中创建嵌套条目

时间:2020-04-23 08:21:03

标签: javascript contentful contentful-management

我使用的是Contentful提供的Content-Managemen-API。

我正在使用它在空间中创建一个条目,并且效果很好:

const contentful = require('contentful-management')

const client = contentful.createClient({
  accessToken: '<content_management_api_key>'
})


client.getSpace('<space_id>')
.then((space) => space.createEntry('<content_type_id>', {
  fields: {
    title: { 'de-DE': 'Zusammenfassung', 'en-US': 'Summary' },
    slug: { 'en-US': 'example-app-summary' },
    modules: { 'en-US': [Object] }
  }
}))
.then((entry) => console.log(entry))
.catch(console.error)

我的问题:

我想创建一个嵌套条目。这意味着一个条目包含另一个条目,依此类推。

我尝试过发送令人满意的数据结构:

fields: {
    title: { 'de-DE': 'Zusammenfassung', 'en-US': 'Summary' },
    slug: { 'en-US': 'example-app-summary' },
    modules: { 'en-US': [Object] }
  }

模块属性包含下面显示的另一个条目元数据:

{ type: 'Link', linkType: 'Entry', id: '4Ng6zmj9e8Sw0eaYKQM8Es' }

当我对以上数据进行POST请求时,它确实创建了一个Entry,但是嵌套的Entry无效,我看到了。

enter image description here

问题:

任何人都知道如何创建带有嵌套项目的条目吗?我不确定要发送给API的数据结构是什么。

0 个答案:

没有答案