WorkflowΒΆ

Note

Currently the workflow support is limited to executing transitions on content.

In Plone, content almost always has a workflow attached. We can get the current state and history of an object by issuing a GET request using on any context:

http

GET /plone/front-page/@workflow HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0

curl

curl -i http://nohost/plone/front-page/@workflow -H "Accept: application/json" --user admin:secret

httpie

http -j http://nohost/plone/front-page/@workflow -a admin:secret

python-requests

requests.get('http://nohost/plone/front-page/@workflow', headers={'Accept': 'application/json'}, auth=('admin', 'secret'))
HTTP/1.1 200 OK
Content-Type: application/json

{
  "@id": "http://localhost:55001/plone/front-page/@workflow", 
  "history": [
    {
      "action": null, 
      "actor": "test_user_1_", 
      "comments": "", 
      "review_state": "private", 
      "time": "2016-10-21T19:00:00+00:00", 
      "title": "Private"
    }
  ], 
  "transitions": [
    {
      "@id": "http://localhost:55001/plone/front-page/@workflow/publish", 
      "title": "Publish"
    }, 
    {
      "@id": "http://localhost:55001/plone/front-page/@workflow/submit", 
      "title": "Submit for publication"
    }
  ]
}

Now, if we want to change the state of the front page to publish, we would proceed by issuing a POST request to the given URL:

http

POST /plone/front-page/@workflow/publish HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0

curl

curl -i -X POST http://nohost/plone/front-page/@workflow/publish -H "Accept: application/json" --user admin:secret

httpie

http -j POST http://nohost/plone/front-page/@workflow/publish -a admin:secret

python-requests

requests.post('http://nohost/plone/front-page/@workflow/publish', headers={'Accept': 'application/json'}, auth=('admin', 'secret'))
HTTP/1.1 200 OK
Content-Type: application/json

{
  "action": "publish", 
  "actor": "admin", 
  "comments": "", 
  "review_state": "published", 
  "time": "2016-10-21T19:05:00+00:00", 
  "title": "Published"
}