Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to generate the User-Input XML or JSON Body for executing workflows via REST APIs: The Solution

2015-07-29
04:21 AM
11,253 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see that executing a workflow via REST APIs requires lot of work to be done just to prepare the right User-input XML body. Any mistake and you have some major debugging to do.
- Larger the number of User-Inputs, the bigger is the problem.
- Life is so much easier at the WFA GUI with Display names and tooltip help for User Inputs which are very easy for reading and providing the right values. I don't have any such privileges when manually preparing the User-Input XML body.
- It’s been asked numerous times how to provide User-Input values for type table, or Query (Multi-Select) etc. These are complex User-Input types and has lots of scope for user mistakes.
- I can have User-input dependency at WFA GUI which allows me to make the right selection, but while preparing my XML body I need to take care of it myself.
- An operator is allowed to execute workflows, but the same Display names which help him make the right user-inputs, makes it impossible for him to prepare the user-input body xml. Display names can't be used in in XML body and he can't know the exact parameter names by looking at the Display names. So he need to always contact the Admins/Architects for this. And Architects/Admins can't be expected to keep providing User-Input XML body to operators every operator.
How about if I could enter all the User-Input values in my workflow execution at WFA GUI, I can do a preview which passed to my satisfaction and then I can magically get the XML body for it which I can use to execute my workflow from REST APIs from any client. It could be so very much easy for me than building my User-Input XML body manually.
This is exactly what I'm going to give you right now. You open the WFA in browser, Go to your workflow, Start execution, you input values from GUI reading carefully the display names, preview it to your satisfaction and then get the XML body.
Assume your workflow is called “Workflow to Print a given Message”. It’s a simple workflow with only 1 user-input Displayed as "Message to Print"
Prerequisites:
The following are the one-time prerequisites.
- You need PowerShell 3.0 on your WFA server.
- Import the attached Generate_Workflow_User_Input_Body_in_XML.dar in your WFA. It’s our magical command called "Generate Workflow User Input Body in XML"
- Add credentials of a WFA Admin/Architect in you WFA itself with Name/IP: localhost
Match: Exact
Type: Other
Name/IP: localhost
Username: <WFA Admin/Architect Username>
Password: <User Password>
Steps:
Suppose you have a workflow called "Workflow to Print a given Message". You want to execute it from REST apis and need to prepare the user input XML body.
- Select this workflow and clone it. The workflow clone is the exact copy of your original workflow word by word, input-by-input. It will open in Edit mode with name "Workflow to Print a given Message - copy".
- Add the command "Generate Workflow User Input Body in XML" at the beginning of your workflow. This is a must. This command need to be the first command in your cloned workflow.
- This command requires no input. So for its Parameters just press okay and save the workflow.
- You are done.
- Now Execute the clone workflow. You'll see all the user-inputs available to you. Make your choices as you wish. Preview it to confirm that planning is passed and u have no errors.
- Execute it now.
- You'll see that the our magical command "Generate Workflow User Input Body in XML" has failed in our clone workflow execution. Don't worry, its fate was decided to be so. But it didn't fail before giving me what I really wanted. i.e. my XML body for my real workflow. It displayed it in the GUI as well as saved it in your WFA server @ C:\temp\<workflow_name_dd_MM_yyyy_hh_mm_ss_.xml
- It also deleted all the reservations of this particular failed job. So NO major residue left to be cleaned.
- No matter how many and type of User-Inputs you have in your workflow, this will solve it all.
To summarize:
Clone Your workflow and Add the command "Generate Workflow User Input Body in XML" as your first command.
Start Execution, provide your User-inputs and preview it. Be satisfied and Press Okay.
Now Execute it. After a few scconds this cloned workflow will fail with Error "All done. The Workflow will fail now."
See the command execution logs for this command. You'll see the User-Input XML body. It has also saved the XML file at C:\temp in your WFA server.
Have fun.
sinhaa
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Solved! See The Solution
1 ACCEPTED SOLUTION
sinhaa has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello WFA community users,
Adding the solution for JSON User-Input body as well. The method to use it remains same.
You can download and import the .dar file in WFA4.1 or above. Also providing the command code in .TXT format.
sinhaa
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am getting the following error message when i execute my workflow with the command in it.
Exception calling "Save" with "1" argument(s): "Could not find a part of the path 'C:\temp\TFG27 DS NFS volume Resize - copy__03_10_2016_10_08_36_.xml'."
c:\temp exists on my PC.
PS C:\temp> ls
PS C:\temp>
Any help is much appreciated.
Thanks.,
Promoth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay. First thing I want to tell that DO NOT expect this command to pass. Its made to fail. Yeah not with this error, see here.
The command tries to save the XML file on the WFA server's C:\temp\ . Have you installed your WFA on your PC? Do you have permission to create files in this folder? If not check if C:\temp is on your WFA server or not.
I'll modify the code to perform this check before. Will update the Dar file.
In this image, you should still be getting the Uer-Input XML body in command execution logs even though saving the file failed. You can copy-paste that line.
Sinhaa
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sinhaa has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello WFA community users,
Adding the solution for JSON User-Input body as well. The method to use it remains same.
You can download and import the .dar file in WFA4.1 or above. Also providing the command code in .TXT format.
sinhaa
If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
