Hi,
I’m currently developing an application to automate creation of PDFs. I use an user step to collect data from employees and the data is then sent to Adobes Document Generation API using REST where it gets merged with a .docx template to create a PDF that is then uploaded to SharePoint. The picture below shows the model that is used as the body parameter in the REST operation.
The problem is that we have documents that have different parameters and it would be a lot of work defining different models and operations for all of the documents. Would it be possible to change the input under jsonDataForMerge so that it can accept any type of json data so that I could reuse the same REST operation for multiple calls? (I tried messing with the “undefined” property under models but without success)
For example some calls have this jsonDataForMerge:
{
“project”: “test”,
“drawingNumber”: “A2540”
}
and some calls have:
{
“project”: “test1”,
“inspectionNotes”: “do this”,
“classificationRule”: “ISO611”
}
Then when you set up the machine step with the REST connector you need to initially provide it with a structure that has it all in a variable named the same as the structure that later wont have it all
After you close the machine step you can then provide that step with a structure that doesn’t have it all (and it wont complain when you actually make the call since the element is not mandatory )
Oh and you better keep that “full structure” variable handy if you want to edit that machine step, becouse next time you open the machine step the variable mapping will be gone.
Maybe I was unclear when explaining my problem, what I was looking for was a way to pass parameters without defining any kind of model at all (or rather a specific part of the model needs to be “not defined” since it changes from call to call and has no base structure).
This is what the part of the call that handles the data to add to the .docx template looks like in Postman:
The data in jsonDataForMerge is just based on what “tags” I have in the .docx templates and looks like this:
Project: {{project}}
Drawing Number: {{drawingNumber}}
In this case it happens to be “project” and “drawingNumber” but it can really be whatever. I am keeping track of what parameters are used in different documents in my database (since I have about 50 different templates, and all of them have different questions) with the goal of not having to update/modify the REST connector or the workflow when adding/deleting/changing forms. I am then using a data grid to visualize the correct questions based on what form the user has selected.
Hence the ability to pass any data in the form of {“key1”: “value1”, “key2”: “value2”,…} under the jsonDataForMerge would be super helpful.
If your data is going to be an input to another API call, you can just make the input parameter a single value type text. Then, in your app, use flowscript to gather your data and build it how you need it and then JSON.Encode it and then pass that value into the API. This way, you don’t have to build the connector at all except having that one value.
Thanks for your help! I managed to solve the problem by using a bit of creativity: I defined the required parameters as “global internal” parameters and then used a computed parameter for the body (see the picture below). I prepare the jsonData (the data that is merged with the .docx template) using a script step and then pass it together with the inputUri and outputUri to my machine step. These parameters are then used in the computed body which returns the full json that is required for the API call to Adobes Document Generation API.