All of the info, including the latest PDF manual, is available at OpenCPU.org. Specifically the page about the JavaScript library has a chapter on state.
What you need to do remove the /print
and perform a POST do a function. The result will be a HTTP 201
with a key to the created resources (a file in your case) in the Location
header of the response.
> library(httr)
> req <- POST("http://localhost:1659/ocpu/library/base/R/matrix", body=list(data="1:10", nrow="2"))
> req
Response [http://localhost:1659/ocpu/library/base/R/matrix]
Status: 201
Content-type: text/plain; charset=utf-8
/ocpu/tmp/x0975a128/R/.val
/ocpu/tmp/x0975a128/stdout
/ocpu/tmp/x0975a128/source
/ocpu/tmp/x0975a128/console
/ocpu/tmp/x0975a128/info
> req$headers$location
[1] "/ocpu/tmp/x0975a128/"
> req$headers["x-ocpu-session"]
$`x-ocpu-session`
[1] "x0975a128"