【发布时间】:2019-05-24 00:02:12
【问题描述】:
我正在尝试编写一些基本代码来检索工作区列表并将响应写入文件。我认为这可以转储到 JSON 文件中?
感谢您的任何帮助/建议。
我已经获取了示例 .py 文件并将其修改为如下所示 -
# Install the smartsheet sdk with the command: pip install smartsheet-python-sdk
import smartsheet
import logging
import os.path
import json
# TODO: Set your API access token here, or leave as None and set as environment variable "SMARTSHEET_ACCESS_TOKEN"
access_token = None
print("Starting ...")
# Initialize client
smart = smartsheet.Smartsheet(access_token)
# Make sure we don't miss any error
smart.errors_as_exceptions(True)
# Log all calls
logging.basicConfig(filename='rwsheet.log', level=logging.INFO)
response = smart.Workspaces.list_workspaces(include_all=True)
workspaces = response.data
with open('data.json', 'w') as outfile:
json.dump(workspaces, outfile)
print("Done")
【问题讨论】:
-
您遇到错误了吗?
标签: python smartsheet-api