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: http://docs.octoprint.org/en/master/api/job.html#issue-a-job-command

What I am trying is this:

String OctoprintPrinterCommand "Command [%s]" (gOctoprint) { http=">[*:POST:http://octopi.fritz.box/api/job?apikey=APIKEY:default]" }

and

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
Host: example.com
Content-Type: application/json
X-Api-Key: abcdef...

This could theoretically work:

http=">[*:POST:http://octopi.fritz.box/api/job{X-Api-Key=abcdef...}:{"command":"start"}]"

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"
when
	Item OctoprintPrinterCommand received update
then
    var url = "http://octopi.fritz.box/api/job?apikey=APIKEY"
    var contenttype = "application/json"
    var POSTrequest = '{"command":"' +  OctoprintPrinterCommand.state + '"}'

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

The item has to contain “cancel” etc…

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