Problem Statement:
We've developed a REST provider to download an Excel file, but it seems to be downloading the wrong file. Although the file appears correct in the repository, the downloaded file is incorrect.
Issue description:
This issue likely arises because the Excel file cannot be directly stored in the restResponse within the process flow context.
Proposed Solution:
We addressed this by developing a Custom Plugin that encodes the Excel bytes into Base64 format and stores it in the restResponse. This ensures that the byte data is not corrupted when added to the response.
To make this downloadable, we published a Web Form that accepts the REST provider endpoint and gives the Excel file.
Implementation Steps:
-
Create and Use Custom Plugin in Process Flow:
- Use the provided plugin (CP_streamToBase64.txt) to create a Custom Plugin Activity.
- Add this plugin before the Context Target in your process flow.
- Save the process flow.
- Publish a Web Form:
- Navigate to Configure > Webforms and click ‘PUBLISH Web Form’.
-
- Set:
- Name and Description
- Type: WebPage
- Web Page URL: e.g., DownloadExcel
- Navigation Path and Link Name: e.g., DownloadExcel
- Save and activate the Web Form.
- Set:
- Create WAR File for Web Form:
- Download the attached “DownloadExcel.zip” file and extract its contents to a directory, for example, D:\DownloadExcel.
- Edit the TestExcelDownload.html from the DownloadExcel.zip:
- Line 13: Set your REST endpoint (e.g., http://localhost:82/wsapi/restGet)
- Line 17 (optional): Change the file name if needed. The file will get downloaded with this name.
-
-
- Save the file.
- Now, run the following command to create the WAR file:
-
jar -cvf DownloadExcel.war -C "<FolderPath>" .
- The war file will get created at the drive location. Example output location: D:\DownloadExcel.war
- Place the war file in the shared\webapps directory
- Restart the Portal microservices
- Once restarted, you can access the Web Form from the Dashboard tab.
Clicking the Download Excel button will trigger the REST Provider and download the correct Excel file.
Attached the Custom Plugin code and the html file for the reference
Comments
0 comments
Please sign in to leave a comment.