HTTP JSON POST - I don't get it

I want to talk to my OctoPrint-Powered 3D Printer.
I’m already able to GET some data, but now I would like to add some control.

The API is documented here:

What I am trying is this:

String OctoprintPrinterCommand "Command [%s]" (gOctoprint) { http=">[*:POST:]" }


Selection  	item=OctoprintPrinterCommand  mappings=[start=start, pause=pause, cancel=cancel]

but no luck.

How can I specify the content? Where does the command: go?

I think the command is wrong… i think default must be start, resume and so on …

Try the Commands in a Webbrowser and post the working URL

Based on this api call from your linked api doc:

POST /api/job HTTP/1.1
Content-Type: application/json
X-Api-Key: abcdef...

This could theoretically work:


You could also look into using an http action instead.

I’ve managed to do it with a http action, it is the following:

rule "POST Printer Command"
	Item OctoprintPrinterCommand received update
    var url = ""
    var contenttype = "application/json"
    var POSTrequest = '{"command":"' +  OctoprintPrinterCommand.state + '"}'

    var output = sendHttpPostRequest(url, contenttype, POSTrequest)
    logInfo("Test Octoprint:", output);

The item has to contain “cancel” etc…

However I’m still wondering how to do this directly with an item…