Unable to find proper resource to which can help import external libraries in script snap

Using Script Snap to fetch file document of attachments from JIRA and to encode it, we are unable to add external third party libraries like “request” for python in the directory mentioned as /opt/snaplogic/:-

Below is the script:-

import requests
import base64

url = ‘https://myjira/secure/attachment/1234/sample.txt

res = requests.get(url,headers={“Authorization”:“Basic authentication”})
print(res.content)
print(base64.b64encode(res.content))

We are unable to locate directory /opt/snaplogic/ as we are in the cloudplex.

Any help on this would be appreciated.

Thanks.

The script runs in the context of the JVM, so it is a Jython script rather than a pure python script. Additional python dependencies cannot be installed. Python standard library functions can be used. In this case, use urllib2 instead of the requests library. For more complex use cases, external Java libraries can be loaded for use from the Jython script. See this post for an example.

1 Like

It is possible to configure a path from which to load other libraries for python, though be aware that not all python libraries will work with Jython. See this post:

1 Like