If not otherwise stated OctoPrint’s API expects request bodies and issues response bodies as
To make use of the OctoPrint API from websites other than the OctoPrint web interface, cross-origin resource sharing (CORS) must be enabled. This is the case even when the website in question is served from a different port on the same machine and on localhost.
To enable this feature, set the
allowCrossOrigin key of the
api section in
check the corresponding checkbox in the API settings dialog.
api: enabled: true key: ... allowCrossOrigin: true
This means any browser page can send requests to the OctoPrint API. Authorization is still required however.
If CORS is not enabled you will get errors like the following:
XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin' header is present on the requested resource.