简体   繁体   English

调用外部REST API以获取列表数据

[英]Call external REST API to fetch data for list

我们是否有规定使用外部REST API来获取数据并将其放入列表的允许值中?

Data can be added to Gentics Mesh only via the REST API. 只能通过REST API将数据添加到Gentics Mesh。 You would thus need to first define your schema for your contents. 因此,您需要首先为内容定义模式。

Example: 例:

{
    "name": "test",
    "displayField": "name",
    "segmentField": "",
    "urlFields": [],
    "container": false,
    "fields": [
        {
            "name": "name",
            "label": "Name",
            "required": false,
            "type": "string"
        },
        {
            "name": "ids",
            "label": "IDs",
            "required": false,
            "listType": "number",
            "type": "list"
        }
    ]
}

Next you need to create a project and assign this schema to your project. 接下来,您需要创建一个项目并将此架构分配给您的项目。 This needs to be done only once and can be done via the UI. 只需执行一次即可,并且可以通过UI进行。

Now you can use the REST API and store your contents in Gentics Mesh. 现在,您可以使用REST API并将您的内容存储在Gentics Mesh中。

The POST request needs to contain the language , parentNode and fields . POST请求需要包含languageparentNodefields

POST /api/v1/demo/nodes

{
    "parentNode": {
        "uuid": "960d4632505a445d8d4632505a045d58"
    },
    "language": "en",
    "schema": {
        "name": "test"
    },
    "fields": {
        "name": "MyEntry",
        "ids": [
            1,
            2,
            3
        ]
    }
}

This is how data is being added to Gentics Mesh. 这就是将数据添加到Gentics Mesh的方式。 If you have a source that needs to be pulled regularly I suggest to write a dedicated importer which fetches the data from the source and adds the data via REST in the format that Gentics Mesh understands. 如果您有需要定期拉出的源,我建议编写一个专用的导入器,该导入器从源中获取数据并通过REST以Gentics Mesh可以理解的格式添加数据。

I hope this answers your question. 我希望这回答了你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM