Skip to main content

创建记录

本文提供调用「创建记录」接口的操作示例。

示例:在指定维格表中创建两条新的记录#

假设你有一张维格表,你想在其中创建两条新的记录。

你的操作步骤如下:

  1. 获取你的 API Token。(获取方法

  2. 获取该维格表的 ID。(获取方法

  3. 打开你电脑上的终端,执行下列代码,向服务器发送查询请求(假设 datasheetId 为 dstWUHwzTHd2YQaXEE):

    curl -X POST \https://api.vika.cn/fusion/v1/datasheets/dstWUHwzTHd2YQaXEE/records \-H 'Authorization: Bearer {你的 API Token}' \-H 'Content-Type: application/json' \-d '{    "records": [        {            "fields": {                "体重": "80公斤",                "肩高": "65厘米",                "登记日期": "2020/09/15 17:14",                "胸围": "87厘米",                "体长": "1.2米",                "拍照": [                    {                        "name": "image.png",                        "size": 207456,                        "mimeType": "image/png",                        "token": "space/2020/09/21/f577af8bd73f44c79dfc28408eaeff83",                        "width": 374,                        "height": 347                    }                ],                "登记员": [                    {                        "type": "Member",                        "name": "Bruce · K"                    }                ],                "性别": "男孩",                "昵称": "安安",                "年龄": "5岁"            }        },        {            "fields": {                "体重": "88公斤",                "肩高": "66厘米",                "登记日期": "2020/09/15 17:14",                "胸围": "89厘米",                "体长": "1.4米",                "拍照": [                    {                        "name": "image.png",                        "size": 395220,                        "mimeType": "image/png",                        "token": "space/2020/09/21/c42f476c01c24e8ca7908188d460f8f1",                        "width": 400,                        "height": 347                    }                ],                "登记员": [                    {                        "id": "1291258301781176321"                    }                ],                "性别": "女孩",                "昵称": "佳佳",                "年龄": "6岁"            }        }    ]}'
  4. 服务器会返回下列 JSON 数据包,"records" 下即为新创建的记录数据:

    有关返回结果中各参数的含义,可查看 API 手册

    {    "code": 200,    "success": true,    "data": {        "records": [            {                "recordId": "reclxDBUBjQo6",                "createdAt": 1600708683000,                "fields": {                    "体重": "80公斤",                    "肩高": "65厘米",                    "登记日期": "2020/09/15 17:14",                    "胸围": "87厘米",                    "体长": "1.2米",                    "拍照": [                        {                            "id": "atcUJME9gbmFQ",                            "name": "1.png",                            "size": 207456,                            "mimeType": "image/png",                            "token": "space/2020/09/21/f577af8bd73f44c79dfc28408eaeff83",                            "width": 374,                            "height": 347,                            "url": "https://s1.vika.cn/space/2020/09/21/f577af8bd73f44c79dfc28408eaeff83"                        }                    ],                    "登记员": [                        {                            "id": "1286184164530659329",                            "type": "Member",                            "name": "Bruce · K",                            "avatar": "https://s1.vika.cn/public/2020/08/03/574bcee4cfc54f6fbb7d686bb237f6f3"                        }                    ],                    "性别": "男孩",                    "年龄": "5岁"                }            },            {                "recordId": "reckuCT1F1Asn",                "createdAt": 1600708683000,                "fields": {                    "体重": "88公斤",                    "肩高": "66厘米",                    "登记日期": "2020/09/15 17:14",                    "胸围": "89厘米",                    "体长": "1.4米",                    "拍照": [                        {                            "id": "atcSvAn7wEBtJ",                            "name": "image.png",                            "size": 395220,                            "mimeType": "image/png",                            "token": "space/2020/09/21/c42f476c01c24e8ca7908188d460f8f1",                            "width": 400,                            "height": 347,                            "url": "https://s1.vika.cn/space/2020/09/21/c42f476c01c24e8ca7908188d460f8f1"                        }                    ],                    "登记员": [                        {                            "id": "1291258301781176321",                            "type": "Member",                            "name": "小葵🌻",                            "avatar": "https://s1.vika.cn/public/2020/09/07/dbfe6ceccbdb4d5bbc1fd129566dea89"                        }                    ],                    "性别": "女孩",                    "年龄": "6岁"                }            }        ]    },    "message": "SUCCESS"}