【发布时间】:2017-09-06 21:10:35
【问题描述】:
我正在尝试将 REST API 与 Octoprint 一起使用
我的代码如下:
import requests
import json
api_token = '7598509FC2184985B2B230AEE22B388F'
api_url_base = 'http://10.20.10.189/'
api_url = '{}{}'.format(api_url_base, 'api/job')
headers = {
'Content-Type': 'application/json',
'apikey': api_token,
'"command"': '"pause"',
'"action"': '"pause"'
}
response = requests.post(api_url, headers=headers)
print(response)
我的结果是
<Response [400]>
我现在有点不知所措
【问题讨论】:
-
一个 HTTP 400“错误请求”响应告诉您由于语法无效,服务器无法理解该请求。您的请求中的某些内容格式不正确。
标签: python-3.x rest octoprint