How to access resource json file using Beanshell code

Confluence User - 19 Jan, 2024

I have a requirement to consume data from JSON file. I have uploaded JSON file to the resources list of the project.

Is there a way that I can access the same JSON file in my Beanshell code?


Regards,

Taj

beanshell

4


19 Jan, 2024
confluenceUser
confluenceUser

Every Joget resource has a hash variable you can use (#appResource.id#) see screenshot below:

19 Jan, 2024
confluenceUser
confluenceUser

I am getting the only path of the resource item using the hash variable but I want to read data from the JSON file in beanshell. like below - 

22 Jan, 2024
confluenceUser
confluenceUser

Try using absolute URL first to check its working correctly. Then you can use Hash Variable, it will help to avoid any gap in hash variable usage. 

In addition, for testing only try removing permission.  

24 Jan, 2024
confluenceUser
confluenceUser

Thanks for replying,

Initially, I tried using the absolute path and the path was referring to the folder outside of the Joget setup folder on the server. and I was able to read JSON file content.


but due to some security reasons, I need to implement the authentication for API (JSON file) while accessing the JSON inside Beanshell. that's why I placed the JSON file in the resources section (with the thought that the JSON file would use the browser authentication)

 and accessed through Beanshell but was not able to read the file content.


My problem statement is simple - I need to read the content of the JSON file (in Beanshell). The JSON file is available on the server where Joget has been set up.



RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print