Skip to main content

更新记录

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

示例:更新指定维格表的两条记录#

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

你的操作步骤如下:

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

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

  3. 获取想要更新的 2 条记录的 ID。(获取方法

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

    curl -X PATCH \https://api.vika.cn/fusion/v1/datasheets/dstWUHwzTHd2YQaXEE/records \-H 'Authorization: Bearer {你的 API Token}' \-H 'Content-Type: application/json' \-d '{    "records": [        {            "recordId": "recbaKEuZ9gDC",            "fields": {                "昵称": "安安",                "体重": "90公斤"            }        },        {            "recordId": "rec09dm5nsmS6",            "fields": {                "昵称": "佳佳",                "体重": "89公斤"            }        }    ]}'
  5. 服务器会返回下列 JSON 数据包,"records" 下即为更新后的记录数据:

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

    {    "code": 200,    "success": true,    "data": {        "records": [            {                "recordId": "recbaKEuZ9gDC",                "createdAt": 1600431195000,                "fields": {                    "体重": "90公斤",                    "肩高": "65厘米",                    "登记日期": "2020/09/15 17:14",                    "胸围": "87厘米",                    "体长": "1.2米",                    "拍照": [                        {                            "id": "atcPtxnvqti5M",                            "name": "6.gif",                            "size": 33914,                            "mimeType": "image/gif",                            "token": "space/2020/09/22/01ee7202922d48688f61e34f12da5abc",                            "width": 240,                            "height": 240,                            "url": "https://s1.vika.cn/space/2020/09/22/01ee7202922d48688f61e34f12da5abc"                        }                    ],                    "登记员": [                        {                            "id": "1286184164530659329",                            "type": "Member",                            "name": "Bruce · K",                            "avatar": "https://s1.vika.cn/public/2020/08/03/574bcee4cfc54f6fbb7d686bb237f6f3"                        }                    ],                    "性别": "男孩",                    "昵称": "安安",                    "年龄": "5岁"                }            },            {                "recordId": "rec09dm5nsmS6",                "createdAt": 1600431195000,                "fields": {                    "体重": "89公斤",                    "肩高": "66厘米",                    "登记日期": "2020/09/15 17:14",                    "胸围": "89厘米",                    "体长": "1.4米",                    "拍照": [                        {                            "id": "atcPtxnvqti5M",                            "name": "6.gif",                            "size": 33914,                            "mimeType": "image/gif",                            "token": "space/2020/09/22/01ee7202922d48688f61e34f12da5abc",                            "width": 240,                            "height": 240,                            "url": "https://s1.vika.cn/space/2020/09/22/01ee7202922d48688f61e34f12da5abc"                        }                    ],                    "登记员": [                        {                            "id": "1291258301781176321",                            "type": "Member",                            "name": "小葵🌻",                            "avatar": "https://s1.vika.cn/public/2020/09/07/dbfe6ceccbdb4d5bbc1fd129566dea89"                        }                    ],                    "性别": "女孩",                    "昵称": "佳佳",                    "年龄": "6岁"                }            }        ]    },    "message": "SUCCESS"}