python - 如何调试 Python Google API 接口(interface)?

标签 python google-api google-api-python-client

我正在尝试使用 Google Calendar API v3 调试我的界面。我正在用 python 编写代码并使用我能找到的 API 示例。我想确保向 API 发送正确的 html 字符串。我看到代码是如何构建字符串和插入参数的,但我不知道在 execute() 命令中发送的实际字符串是什么。

有没有办法打印正在发送而不是执行的 html 字符串?请举例。

http = httplib2.Http(cache=".cache")
http = credentials.authorize(http)

service = build("moderator", "v1", http=http)

series_body = {
    "description": "Share and rank tips for eating healthy and cheap!",
    "name": "Eating Healthy & Cheap",
    "videoSubmissionAllowed": False
    }

# How Do I print the string rather than execute?
series = service.series().insert(body=series_body).execute()
print "Created a new series"

最佳答案

您可以设置 httplib2.debuglevel = 4 以在 stdout 上打印出 header 和请求/响应主体:

http://code.google.com/p/google-api-python-client/wiki/Debugging

关于python - 如何调试 Python Google API 接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10694597/

相关文章:

python - 尝试创建 python 程序,但使用 def 进行了简化

python - 如何使用Python OpenCV在cv2.putText中制作黑色背景

java - 从 Oauth2 Google Contacts API 获取用户信息

python - 如何在没有 python oauth2client lib 的情况下实现谷歌登录混合服务器端流程

Jupyter笔记本中的python3安装模块apiclient错误

python - 如何列出 Google Merchant Center Feed

python - 如何在 Python 的同一索引中将数组的每个数字相乘?

python - 在 Python 中实现运算符优先级的一般方法是什么

php - 代币必须是短暂的代币,并且在合理的时间范围内

android - 使用 Google+ API 获取用户凭据