智能表格添加数据报错,查不出具体原因?

2024/12/13
提问

参考文档:https://developer.work.weixin.qq.com/document/path/100224#%E6%B7%BB%E5%8A%A0%E8%AE%B0%E5%BD%95

返回结果:

{'errcode': 2543303, 'errmsg': 'SmartsheetV2 Service Error, hint: [1734061551123491932172958], from ip: 52.80.43.60, more info at https://open.work.weixin.qq.com/devtool/query?e=2543303'}


相关代码:

def write_to_excel(access_token, data_list):
    api_url = "https://qyapi.weixin.qq.com/cgi-bin/wedoc/smartsheet/add_records?access_token=" + access_token
    headers = {
        "Content-Type": "application/json",
    }
    docid = "dcd6CpHdzQe2AN111OC49OR-ox5x_r86VEbfFxKKkbqPiFDQmoaelKBJD24uYykgTgOkVXHArkCEN8bKVHdPnV7A"
    sheet_id = "仪表盘1"
    payload = {
        "docid": docid,
        "sheet_id": sheet_id,
        "key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE",
        "records": [{
            "values": {
                "次数": [{
                    "type": "text",
                    "text": "2"
                }],
                "项目":[{
                    "type": "text",
                    "text": "项目1"
                }],
                "服务": [{
                    "type": "text",
                    "text": "服务1"
                }],
                "发布状态": [{
                    "type": "text",
                    "text": "success"
                }],
                "发布人": [{
                    "type": "text",
                    "text": "何瑾"
                }],
                "发布分支": [{
                    "type": "text",
                    "text": "release"
                }],
                "地址": [{
                    "type": "text",
                    "text": "http://xxx/xx"
                }],
            }
        }]
    }
    response = requests.post(api_url, data=json.dumps(payload), headers=headers)
    print("response————————", response)
    if response.status_code == 200:
        print("response.json()————————", response.json())
        return response.json()
    else:
        raise Exception(f"Failed to write data to Excel. Status code: {response.status_code}, Error: {response.text}")


回答·2
2024/12/13
是的,创建的时候"doc_type": 10,


赞同
评论
提问者认同了该回答

您好,请问确认这是智能表格吗?

赞同 1
评论 4
2024/12/13
是的,请看我的评论回复
赞同
回复
回复 2024/12/13
子表id有问题,仪表盘不支持通过API编辑。
赞同
回复
回复 2024/12/13
仪表盘已删除,执行还是不行同样错误,如何查询子表id呢?
赞同
回复
回复 2024/12/13
查询子表,不传入sheet_id
https://developer.work.weixin.qq.com/document/path/99911
赞同
回复
你还未登录,请先登录