【发布时间】:2020-01-13 10:11:21
【问题描述】:
我正在用 Python(3.7.4,Windows 10)为 POST 请求(REST API)编写脚本,对象是从另一个数据库检索数据并将其移动到另一个数据库。
from os import getenv
import requests
# header includes login credentials and content type
header = {'access_key': "key", "access_token": getenv("token1"), 'content-type': 'application/json'}
# Body includes table names and other specified data to retrieve
body = {
# table names etc.
}
# Post request and printing of the post request text
post_r = requests.post(url = POST_url, data = body, headers = header)
post_text = post_r.text
print(post_text)
这会抛出一个 HTTP 错误状态代码 500。我应该在代码中进行哪些更改才能正确打印 post_text?
【问题讨论】:
标签: python python-3.x rest post python-requests