Sunday, February 11, 2024

HTTP Receiver | How to retrieve file content

Create a HTTP API and apply Basic Authentication Policy



  • Consumers will send a query parameter (filename) for which they want to retrieve the file content
  • After receiving GET request , BW application will search for the requested file in a particular directory where all files are stored
  • It will read the contents of file and send those file content back in response.

Complete Flow:


First, open HTTP palette and then select HTTP Receiver activity and paste it on canvas.
Next, specify the parameters as shown in below image.

HTTP Connector details..


Next, place a Log activity for debugging purpose. But, it's not mandatory.



Read File activity
This is important to read the content as per the file name specified. Do the file name mapping as shown below..


Log Activity


HTTP Response:
Map ReadFile response to HTTP Response ->asciiContent


Implementation and configuration is completed. Now, we need to test it from PostMan.

http://localhost:8080/filecontents?filename=emp.txt

Here, the file name is emp.txt.....



How to create an authentication policy and apply it on API

First, create a policy as shown below..


Select Policy and specify required configurations.. and click on Finish.


Then, enter user name and password..


Finally, apply this policy to HTTP Receiver activity as shown below..



That's all. It's very simple. 

Thanks for reading :-)

No comments:

Post a Comment

XML Palette Activities

The XML palette provides activities for parsing XML strings into schemas and rendering schemas into XML strings Parse XML: Parse XML  is use...