【发布时间】:2018-09-27 14:44:55
【问题描述】:
我无法理解在何处添加 API 文档定义的参数。以 BeeBole 的documentation 为例,它指定要通过 ID 获取缺勤,需要以下请求:
{
"service": "absence.get",
"id": "absence_id"
}
他们在文档中只提供一个 URL:
BeeBole 接受以下 URL 的 json-doc 格式的 HTTP POST 请求: https://beebole-apps.com/api/v2
这将如何在 Python 请求的上下文中实现?我尝试过的以下代码返回 404:
import requests
payload = {
"service": "absence.get",
"id": "absence_id"
}
auth = {
"username": "API_token",
"password": "x"
}
url = "https://beebole-apps.com/api/v2"
req = requests.get(url, params=payload, auth=auth).json()
【问题讨论】:
-
如果是 404,你可能需要仔细检查你使用的 url
-
它是他们文档中列出的唯一 URL,你确定它与我的参数无关吗?
-
他们期望的是 JSON 文档,但您发送的是 URL 查询。
-
嗯,您确定需要
auth密钥参数吗?headers中没有? -
我可能会使用他们将其包含在 URL 中的示例,因此感谢您选择此内容。
标签: python api python-requests documentation