【问题标题】:How do I debug Python Google API interface?如何调试 Python Google API 接口?
【发布时间】:2012-05-22 01:07:50
【问题描述】:

我正在尝试使用 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"

【问题讨论】:

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


    【解决方案1】:

    您可以设置httplib2.debuglevel = 4 在标准输出上打印标题和请求/响应正文:

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

    【讨论】:

      猜你喜欢
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      • 2013-01-15
      • 1970-01-01
      • 2020-07-06
      • 2021-08-05
      • 1970-01-01
      • 2021-04-18
      相关资源
      最近更新 更多