简体   繁体   中英

Call external REST API to fetch data for list

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

Data can be added to Gentics Mesh only via the REST API. 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.

Now you can use the REST API and store your contents in Gentics Mesh.

The POST request needs to contain the language , parentNode and fields .

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. 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.

I hope this answers your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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