I am trying to use the REST API with Octoprint
My code is as follows:
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)
my result is
<Response [400]>
I am kind of at a loss at the moment
I have also been dealing with this problem (Octoprint API) for a long time. Urllib3 example here is functional, but when I ported it to python3 requests, I got <Response [400]>.
The magic is in this (json=data) <Response [204]>