Using Templates in HTTP-API-Requests

Questions, comments, discussions. Over time certain topics might be moved to their own category.
Post Reply
measles
Posts: 1
Joined: Sun Sep 13, 2020 11:44 am

Using Templates in HTTP-API-Requests

Post by measles »

At first: I really start to like Mayan EDMS since I first experimented with it about four days ago. To check whether it fully suits my needs I call for help on the following matter:

I want to create a filing cabinet automatically within a workflow and then fill this cabinet with the document of the workflow. Unfortunately I did not find any ready-made actions for this, so I guess I have to write one myself.

So far I'm at the point where I create the filing cabinet with the following payload using the REST-API:

Code: Select all

{
    "label": "NAME OF CABINET"
    "parent": "7"
}
to /api/cabinets/ via a POST. This works also very well.

Actually I would like the name of the filing cabinet to have YYYY-MM-DD as format, but unfortunately I can't seem to use Django templates. It outputs:

WorkflowStateActionError; payload JSON error: Expecting value: line 2 column 14 (char 16)

when I use something like

Code: Select all

{
    "label": {{ entry_log.workflow_instance.document.latest_version.file }},
    "parent": "7"
}
What did I do wrong? Help is greatly appreciated. Thank you :)
User avatar
rosarior
Developer
Developer
Posts: 549
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: Using Templates in HTTP-API-Requests

Post by rosarior »

The error means that the final string is not a valid JSON. Try adding quotes to the first key:

Code: Select all

{
    "label": "{{ entry_log.workflow_instance.document.latest_version.file }}",
    "parent": "7"
}
Post Reply