【问题标题】:Getting HTTP 404 when using Requests and EdgeGrid使用 Requests 和 EdgeGrid 时获取 HTTP 404
【发布时间】:2015-05-11 10:54:48
【问题描述】:

请帮忙。

我需要在 CDN akamai 中创建监控 http 错误的值。 我如何使用 API 做到这一点?

import requests
from akamai.edgegrid import EdgeGridAuth
from urlparse import urljoin
baseurl = 'baseurl'
s = requests.Session()
s.auth = EdgeGridAuth(
client_token='client_token',
client_secret='client_secret',
access_token='access_token
)
result = s.get(urljoin(baseurl, '/media-reports/v1/download-delivery/19')) # 19 - ID 200 http requests
result.json()

从此代码中我得到 404 状态码...

所以问题:1)为什么我有 404 响应? :) 2)我需要baseurl吗?还是需要别的东西?

谢谢大家。

【问题讨论】:

  • baseurl 的真正价值是多少? urljoin() 的结果是什么? (尝试打印)。
  • baseurl - 这是 api akamai 的个人网址

标签: python api http cdn akamai


【解决方案1】:

调试此问题的最佳方法是在 HTTP 级别打开调试。这将向您准确显示发送和返回的内容。您可以使用以下代码执行此操作:

        import httplib as http_client
        http_client.HTTPConnection.debuglevel = 1
        logging.basicConfig()
        logging.getLogger().setLevel(logging.DEBUG)
        requests_log = logging.getLogger("requests.packages.urllib3")
        requests_log.setLevel(logging.DEBUG)
        requests_log.propagate = True

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    相关资源
    最近更新 更多