Question
Is it possible to modify the document body for the verification stage task using FlexiCapture API?
Answer
The base schema is described in the documentation: Verifying the documents
For the demonstration, the JSON format of API calls will be used.
For testing purposes, it is expected that the Invoice number will be changed to the desired value.
The general sequence of actions will be:
- First, it is mandatory to connect to the Web API Service using the OpenSession method. Please make sure to specify the role type and the station type. As the output, it will return SessionID for further usage:
- After opening the session, navigate to the desired project and access it using the OpenProject method as well as the earlier received SessionID and project name as a string or unique ID. As output, it will return the unique ID of the project:
-
Get Task specifying the SessionID, ProjectID, and StageType. As the test batch is on verification the following parameters will be used:
As the output, it will return a unique TaskID which will be used later.
- The next step will be opening the batch and getting the document out. To get the correct batch ID, use the GetTaskInfo method specifying the TaskID from the previous step:
- With this information now the batch can be opened using the OpenBatch method.
- Request the list of documents either in a Task or the Batch using the appropriate method described before. This will show extended information about the document in the Batch or Task respectively. Note: that for general sequence this step is not needed and is done purely for testing purposes. However, this can be useful if the information of document ID is needed, the easy way to obtain it is shown in the screenshot below:
-
Load the document from the server to get the document body:
As an output, the whole document body in XML format will be received, which can be copied into any text editor for further manipulation:
Now the modifications to the XML body can be done to indicate the success of the upload, i.e. the invoice number will be changed:
On the screenshot, the text block of the "Invoice Number" field with the actual text and properties can be seen, for the changes to apply in the FlexiCapture also need to mark it as Verified change the property to true, and remove the Unchanged tag from the document, by default, it is located in the first several rows of the document. The final result will look like this:The property to remove is Unchanged:
- After this is done save the file and upload it back to the server. Using the same endpoint to work with files but this time Action parameter should be set to Save. Also, previously in streamName and blob the DocumentBody and 0 respectively were set, as the data was receiving, now while sending data to the server streamName will remain the same value(DocumentBody) but must be encoded into Base64, to do that any online encoder can be used as the value will remain static. And blob will be the uploaded file which can be chosen via FileExplorer:
The correct output, in this case, will be Status: 200 OK and 0 in the body, as shown on the screenshot:
- At this point, the document body is updated on the server but the task is still not accessible as it is locked using the GetTast method. To return it to the server use the CloseTask method and send it to the same stage or a different stage:
This will send the test task to the Verification Postprocessing stage allowing it to go further by the workflow.
- The changes to the document can be seen only after the batch is closed using the CloseBatch method.
- As can be seen from the screenshot below, the Invoice Number is changed to the one specified in XML:
Comments
0 comments
Please sign in to leave a comment.